Awesome Reviewers

Reviewer · AI

LLM context alignment

When a prompt tells a model to rely on prior context (e.g. "the conversation above", "read the conversation above", "synthesize the responses above"), verify end-to-end that the referenced turns are actually passed to and seen by the model in that position — do not just assume it from the calling code. Several bugs arose from this gap: a `messages=` kwarg...

Instruction

When a prompt tells a model to rely on prior context (e.g. “the conversation above”, “read the conversation above”, “synthesize the responses above”), verify end-to-end that the referenced turns are actually passed to and seen by the model in that position — do not just assume it from the calling code. Several bugs arose from this gap: a messages= kwarg that may not be forwarded by Agent.run at all (only verified against a stub, not the real LLM call path), a helper that dropped the newest turn via split_last_turn so the agent never received the very content the prompt told it to build on, and prompts whose “above” framing silently depends on an internal ordering detail (task appended after messages) that could change without the prompt being updated. Guard against this by: (1) writing prompts so they degrade gracefully or asserting non-empty context before claiming “the conversation above” contains something, (2) testing the real Agent.run/LLM-call path (not just a mocked stub) to confirm history actually reaches the request payload in the expected order, and (3) when refactoring how turns are selected or trimmed (e.g. split_last_turn, messages_for), explicitly verify which turns survive and that they match what the prompt claims the model will see.

Example of a defensive check:

prior_turns = messages_for(current_agent.agent_name or "", self.conversation)
if not prior_turns:
    raise ValueError("Expected prior conversation turns but found none")
current_agent.run(task=task, messages=prior_turns, **kwargs)