Skip to content

Restore original task instructions after native compaction - #109

Draft
spruceb wants to merge 2 commits into
mainfrom
spruce/sts-native-compaction
Draft

spruceb wants to merge 2 commits into
mainfrom
spruce/sts-native-compaction

Conversation

@spruceb

@spruceb spruceb commented Sep 11, 2026

Copy link
Copy Markdown

Anthropic native compaction returns a generic user message, Please continue working., after its summary. The generator previously treated any user text as evidence that the original task survived, so that continuation suppressed restoration of the task instructions.

Check for the actual original input content instead. This restores missing instructions after Anthropic compaction while recognizing OpenAI's preserved inputs even when compaction assigns new IDs and source="generate". The checkpointed original-input mechanism remains unchanged. Also replace the stale README warning that native compaction is disabled.

Validation:

  • 35 focused compaction/generator/checkpoint tests and 13 subtests pass against Inspect 2203ee7a8, including Anthropic's continuation shape, repeated compactions without duplicate reminders, checkpoint restoration, and reconstructed OpenAI inputs.
  • The new generic-continuation regression fails against the original f98d522 implementation.
  • Ruff lint/format and git diff --check pass. Changed agent source has no type diagnostics with the repository-pinned Inspect; the changed-file type check reports 0 errors and 38 existing dependency typing warnings in tests.

Copilot AI lite review requested due to automatic review settings September 11, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores original task instructions after native compaction and updates related documentation and tests.

Changes:

  • Detects preserved input content across providers.
  • Expands compaction and checkpoint regression coverage.
  • Updates native compaction documentation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Summary
packages/agents/tests/test_checkpoint_generator.py Tests reminder restoration after checkpoint resume.
packages/agents/tests/test_agent.py Covers native continuation and reconstructed inputs.
packages/agents/src/metr_agents/agents.py Adds content-based preservation detection.
packages/agents/README.md Documents enabled native compaction behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +384 to +397
user_messages = [message for message in messages if message.role == "user"]
user_text = "\n".join(message.text for message in user_messages)
user_content = [
content
for message in user_messages
if not isinstance(message.content, str)
for content in message.content
]
return all(
content.text in user_text
if isinstance(content, inspect_ai.model.ContentText)
else content in user_content
for content in input_content
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants