This is an automated email from the ASF dual-hosted git repository.
wenjin272 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-agents.git
The following commit(s) were added to refs/heads/main by this push:
new fe356f32 [fix] Rename format_string positional param to avoid {text}
kwarg collision (#792)
fe356f32 is described below
commit fe356f322b1742735ff3abe25212ab0e2573bb3d
Author: Wenjin Xie <[email protected]>
AuthorDate: Mon Jun 8 14:39:00 2026 +0800
[fix] Rename format_string positional param to avoid {text} kwarg collision
(#792)
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
---
python/flink_agents/api/prompts/utils.py | 4 ++--
python/flink_agents/api/tests/test_prompt.py | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/python/flink_agents/api/prompts/utils.py
b/python/flink_agents/api/prompts/utils.py
index 208ff902..3d18eb53 100644
--- a/python/flink_agents/api/prompts/utils.py
+++ b/python/flink_agents/api/prompts/utils.py
@@ -35,7 +35,7 @@ class SafeFormatter:
return str(self.kwargs.get(key, match.group(0)))
-def format_string(text: str, **kwargs: str) -> str:
+def format_string(_template: str, **kwargs: str) -> str:
"""Format a string with kwargs."""
formatter = SafeFormatter(kwargs=kwargs)
- return formatter.format(text)
+ return formatter.format(_template)
diff --git a/python/flink_agents/api/tests/test_prompt.py
b/python/flink_agents/api/tests/test_prompt.py
index 599e600d..78ec26df 100644
--- a/python/flink_agents/api/tests/test_prompt.py
+++ b/python/flink_agents/api/tests/test_prompt.py
@@ -128,3 +128,12 @@ def test_prompt_contain_json_schema() -> None:
text=f"The json schema is
{LocalPrompt.model_json_schema(mode='serialization')}",
)
prompt.format_string()
+
+
+def test_prompt_variable_collides_with_internal_param() -> None:
+ # `text` and `template` are natural template variables that must not
collide
+ # with the internal positional parameter of format_string.
+ prompt = Prompt.from_text(text="Summarize this {text}, using {template}")
+ assert prompt.format_string(text="article", template="bullets") == (
+ "Summarize this article, using bullets"
+ )