Skip to content

Enhance router agent resilience and inject project overview context#116

Merged
presstab merged 4 commits intomasterfrom
salvage_router
Jul 18, 2025
Merged

Enhance router agent resilience and inject project overview context#116
presstab merged 4 commits intomasterfrom
salvage_router

Conversation

@presstab
Copy link
Owner

Overview
This update strengthens the command‐routing logic by introducing a fallback “salvage” flow that reformats malformed LLM outputs, reduces duplicate parsing code, and integrates the project’s high-level overview directly into the system prompt. The deprecated get_project_summary tool has been removed in favor of on-the-fly context injection. Prompt guidelines have also been refined to clarify when to invoke the /code command.

What This Means for Users

  • The agent will recover more gracefully from unexpected or malformed LLM responses, asking follow-up questions only when genuinely needed.
  • The system automatically includes a concise project summary in its reasoning, improving overall relevance without manual file reads.
  • Code generation boundaries are clearer: the router will no longer launch a full /code agent for simple questions or text-only tasks.

A Closer Look at the Changes

  • .gitignore

    • Added a new entry for runs/ to prevent local run artifacts from being tracked.
  • CommandInterpretationAgent (router_agent.py)

    • Inserted add_project_summary() during prompt construction to supply the agent with an “overview” file from the project state.
    • Centralized JSON parsing: moved message append and decision‐handling into a single flow after successful parsing.
    • On JSON decoding failures, triggers a salvage routine:
      • Builds a new prompt from router/salvage_response.md
      • Calls the “quick_reasoning” model to reformat the LLM output
      • Retries parsing and falls back to an error message if salvage also fails
  • MessageBuilder (message_builder.py)

    • Introduced add_project_summary() method to include the overview file in outgoing system messages when available.
  • agent_tools.py

    • Removed the legacy get_project_summary() function.
    • Expanded documentation for get_indexed_files_context() to emphasize its role in serving key file summaries.
  • Prompt Updates

    • router/salvage_response.md: New template instructing how to reformat malformed JSON responses into the expected schema.
    • router/select_command.md: Refined rule on /code usage—clarifies that code agent calls should be reserved for actual code edits, not simple Q&A or planning tasks, and adds guidance to always confirm before invoking /code when in doubt.
      Generated by JrDev AI using o4-mini-2025-04-16

presstab added 4 commits July 18, 2025 08:25
…estions

Refine instruction 7 to limit `/code` use to coding tasks and discourage it for simple plans or text, and add instruction 10 to avoid auto-launching `/code` on user questions and prompt for permission.
…uter agent

Add add_project_summary method to MessageBuilder to include an overview file when present and invoke it in CommandInterpretationAgent. Remove deprecated get_project_summary tool and function, update get_indexed_files_context description, and refactor router agent JSON parsing to separate error handling from decision logic.
Introduces a secondary LLM call to recover when the router agent fails to parse the initial JSON response. A new prompt template guides the model to re-format the malformed output into the expected schema, reducing user-visible errors and improving robustness.
- Expanded rule 10 to explicitly list question patterns ("How do I", "What is", "Where is") that should not trigger automatic code generation
- Added requirement to confirm intent when a question and code request are combined
@presstab presstab merged commit 10cbc68 into master Jul 18, 2025
@presstab presstab deleted the salvage_router branch August 22, 2025 22:56
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.

1 participant