Repository navigation
[Deep Agent 12/15] Specialised subagents + Langfuse prompt management (#48) - #61
stavp-star wants to merge 2 commits into
Conversation
- subagents.py: schema-scout, value-resolver, result-verifier with explicit tool allow-lists, own prompts, skills, context/date middleware, tool-call cap and optional smaller model (DEEP_AGENT_SUBAGENT_MODEL) - prompt_registry.py: deep-agent/<key> text prompts fetched from Langfuse by label (DEEP_AGENT_PROMPT_LABEL) with packaged .md fallback; PromptRefreshMiddleware serves label changes without a redeploy - run config links generations to the served prompt version (langfuse_prompt metadata) and records prompt_source/prompt_version - executed_queries reducer de-duplicates records (subagent state round trips re-sent the parent's history) - scripts/sync_deep_agent_prompts.py pushes packaged prompts to Langfuse Closes #48 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'t refetched per model call The Langfuse SDK caches fetched prompts but not misses; PromptRefreshMiddleware calls load_prompt on every model call, so an absent prompt (404 -> fallback) cost a network round trip on each call. Misses are now remembered for DEEP_AGENT_PROMPT_CACHE_TTL_S. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Follow-up fix pushed to this branch ( 🤖 Generated with Claude Code |
benb-mafat
left a comment
There was a problem hiding this comment.
i dont see any prompts in langfuse or actually fetched. also subagents may be wasteful and need to think if these are worth adding. maybe location sub agent is needed.
Closes #48 · Part of epic #49 · Stack position 12/15. Base:
deep-agent/40-guidance(#60), auto-retargets on merge.What
Subagents (
deep_agent/subagents.py), delegated to withtask:schema-scoutsearch_metadata,get_database_tables,get_table_columns,get_table_profile,get_column_profile,get_table_relationshipsvalue-resolversearch_column_values,get_column_distinct_values,get_column_profile,search_business_terms,resolve_location_to_wkt,get_sample_rowsresult-verifierexecute_trino_query,get_sample_rowsEach subagent gets its own prompt (
prompts/<name>.md), the skills, a tool-call cap (DEEP_AGENT_SUBAGENT_MAX_TOOL_CALLS), the built-in tool filter, andDeepAgentContextMiddleware. That closes the #55 limitation: subagents now see the request'sconnection_id(tested) and today's date (tested).DEEP_AGENT_SUBAGENT_MODELoptionally runs subagents on a smaller or faster model. The general-purpose subagent stays available; the main prompt names the three specialists and says to skip delegation for simple questions.Bug found and fixed: deepagents passes the parent's state into a subagent and returns the subagent's full state as an update. With the append reducer from #58, every
taskcall would have duplicated the parent'sexecuted_queries. They now merge with a de-duplicating reducer keyed by(query_id, executed_sql).Prompt management (
deep_agent/prompt_registry.py)deep-agent/system,deep-agent/schema-scout,deep-agent/value-resolver,deep-agent/result-verifier, fetched by label (DEEP_AGENT_PROMPT_LABEL, defaultproduction) with the SDK cache (DEEP_AGENT_PROMPT_CACHE_TTL_S, default 60 s)..mdis used when Langfuse is unreachable, the prompt doesn't exist yet, orDEEP_AGENT_LANGFUSE_PROMPTS=false.PromptRefreshMiddlewareswaps the leading prompt part of the system message for the currently served version on every model call. Moving a label in Langfuse changes behaviour without a redeploy or agent rebuild (tested). The skills, harness, and memory sections that deepagents appends are preserved.build_run_configputs the served prompt client inmetadata["langfuse_prompt"], so Langfuse links generations to the prompt version (forlangfuse_compare_prompt_versions), and recordsprompt_source/prompt_version.scripts/sync_deep_agent_prompts.py --label staging [--dry-run]pushes the packaged prompts as new versions. Not run: it writes to your Langfuse project, so that's your call.Acceptance criteria
schema-scout,value-resolver(andresult-verifier) exist with explicit allow-lists. A test asserts the tools actually offered to the subagent's model.deep-agent-bench, [Deep Agent 10/15] Bound the agent loop and cut latency: limits, tool surface, connection reuse, caching (#42) #59).SummarizationMiddleware, large-tool-result eviction) are active and unchanged.Testing
tests/deep_agent/test_subagents_prompts.py: 13 tests (full delegation loop, allow-lists, context and date propagation, reducer idempotency, prompt fallback/label/refresh, sync script)🤖 Generated with Claude Code