feat: add agent-based solution generation via Claude Agent SDK#104
Open
feat: add agent-based solution generation via Claude Agent SDK#104
Conversation
Add agent model support to the solution generation pipeline: - Detect -agent suffix models and store problem_dir in GenerationTask - Add --agent-timeout and --agent-cost-limit CLI arguments - Branch execute_task to call generate_agent_solution for agent models - Save .meta.json alongside generated .cpp solutions - Add import json for metadata serialization
- Copy problem dir to temp directory so agent doesn't pollute originals - Makes concurrent runs on same problem safe - Track token usage from streaming message_delta events (only reliable source when timeout kills run before ResultMessage arrives) - Clean up temp dir after extraction
… for agent eval Build dynamic agent prompts from problem config (time/memory limits, subtask counts, interactive vs standard). Write test_all.sh and run_interactive.sh into agent workdir. Embed small sample I/O directly in prompt. Add CLAUDE.md with solving strategy guidance.
Parity mode (--parity flag) strips all test data, helper scripts, checker, and interactor from the agent workspace — matching the Harbor adapter setup where agents must self-test via brute-force cross-validation (对拍). Changes: - agent_interface.py: parity-aware prompt, workspace setup, CLAUDE.md, _get_infra_git_hash(), and enriched build_metadata (timestamp, parity flag) - generate_solutions.py: --parity CLI argument - tests: parity prompt validation (standard + interactive) - docs: solutions repo separation plan (infra_git_hash in meta.json) - .gitignore: exclude .claude/ directory - pyproject.toml: add pytest dev dependency
These belong to the solutions repo separation effort, which is docs-only for now. Removed _get_infra_git_hash(), subprocess import, and the infra_git_hash/timestamp/parity fields from build_metadata().
…n doc Agent always runs without test data — no --parity flag needed. The solutions repo separation plan is not ready to commit.
Move all large string constants (prompt templates, shell scripts, CLAUDE.md content) out of agent_interface.py into a dedicated constants module.
Prompt (initial message) is now lean — only problem-specific info (path, type, limits). CLAUDE.md carries persistent guidance that survives context compaction: self-testing methodology, workflow steps, common mistakes, retreat strategy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-agentsuffix (e.g.,claude-sonnet-4-5-agent)generate_solutions.py— same CLI, just pass an agent model nameFiles
src/frontier_cs/gen/agent_interface.py— core agent lifecycle: prompt construction, SDK invocation, streaming, transcript logging, timeout/cost control, solution extractionsrc/frontier_cs/gen/agent_constants.py— prompt templates, helper shell scripts, CLAUDE.md contentsrc/frontier_cs/models.py—-agentmodel suffix handling in prefix/provider detectionalgorithmic/scripts/generate_solutions.py— agent mode integrationtests/test_agent_interface.py— 18 testsTest plan
pytest tests/test_agent_interface.py— 18/18 pass