Skip to content

Commit 680fe08

Browse files
committed
Fix pyright error and ruff format issues
_message_text: guard the callable result with an isinstance check so pyright accepts the str return (getattr on object yields object). Formatting: restore the blank line before _is_injected_user_text and collapse two over-split string literals in the compact tests.
1 parent fde5e09 commit 680fe08

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎python_agent_harness/prompts.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ def _message_text(msg: object) -> str:
348348
"""Plain text of a Message object or an OpenAI-style dict."""
349349
text = getattr(msg, "text", None)
350350
if callable(text):
351-
return text()
351+
result = text()
352+
if isinstance(result, str):
353+
return result
352354
if not isinstance(msg, dict):
353355
return ""
354356
content = msg.get("content")

‎python_agent_harness/tui.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def _tool_result_preview(content: str) -> str:
103103
# Goal:/Status:/Evidence: labels (anywhere in the block, any lines)
104104
_FINAL_CHECK_RE = re.compile(r"\[FINAL CHECK\].*Goal:.*Status:.*Evidence:", re.DOTALL)
105105

106+
106107
def _is_injected_user_text(text: str) -> bool:
107108
"""True for harness-injected user messages (not user input).
108109

‎tests/test_agent.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,8 +1587,7 @@ def test_compact_keeps_prompts_excluding_nudges_and_frames(self):
15871587
/build switch must not contradict the build notice."""
15881588
session = RecordingSession()
15891589
plan_notice = (
1590-
"The plan at /tmp/x/PLAN.md has been approved, "
1591-
"you can now edit files. Execute the plan"
1590+
"The plan at /tmp/x/PLAN.md has been approved, you can now edit files. Execute the plan"
15921591
)
15931592
loop = AgentLoop(
15941593
session,

‎tests/test_prompts.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,7 @@ def test_plan_exit_notice_is_latest_reminder(self):
389389
the plan->build handoff and supersedes the earlier plan-mode
390390
batch (which is no longer the current mode state)."""
391391
notice = (
392-
"The plan at /tmp/x/PLAN.md has been approved, "
393-
"you can now edit files. Execute the plan"
392+
"The plan at /tmp/x/PLAN.md has been approved, you can now edit files. Execute the plan"
394393
)
395394
msgs = [
396395
{"role": "user", "content": "<system-reminder>\nPlan mode ACTIVE."},

0 commit comments

Comments
 (0)