fix(reply): done-by-user guard keeps tool calls, other people's lines and started tools safe
- A native tool call message with text is not an earlier answer: leaving it out orphaned its role=tool result. Only plain assistant answers are left out. - The guard is off once any tool run started in the reply, whatever it returned: an MCP call with an empty result was not in invoked_tools_history, so a second try could run it again. - HistoryContext.answers marks the lines that are Jarvis's answers to the asker (to_id is the asker); only those leave the history, not someone else saying the same words. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -101,10 +101,12 @@ class Trace:
|
||||
|
||||
@dataclass
|
||||
class HistoryContext:
|
||||
"""Lines for the prompt: the recent window and the search matches, kept apart for labelling."""
|
||||
"""Lines for the prompt: the recent window and the search matches, kept apart for labelling.
|
||||
``answers``: which of those lines are Jarvis's answers to the asker (not shown on its own)."""
|
||||
|
||||
recent: List[str] = field(default_factory=list)
|
||||
matches: List[str] = field(default_factory=list)
|
||||
answers: List[str] = field(default_factory=list)
|
||||
|
||||
|
||||
def _steps_json(steps: list) -> str:
|
||||
@@ -425,4 +427,5 @@ class HistoryStore:
|
||||
debug_log(f"history context: {len(recent)} recent, {len(matches)} matches, "
|
||||
f"~{total:.0f} tokens", "memory")
|
||||
return HistoryContext(recent=[self.format_line(r) for r in recent],
|
||||
matches=[self.format_line(r) for r in matches])
|
||||
matches=[self.format_line(r) for r in matches],
|
||||
answers=[self.format_line(r) for r in recent + matches if r.to_id == asker])
|
||||
|
||||
Reference in New Issue
Block a user