Skip to content

Dev - #31

Merged
MegumiinUwU merged 15 commits into
mainfrom
dev
Jul 2, 2026
Merged

Dev#31
MegumiinUwU merged 15 commits into
mainfrom
dev

Conversation

@Hemdan47

@Hemdan47 Hemdan47 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Hemdan47 and others added 15 commits June 30, 2026 02:33
The generator unconditionally committed `clean_yaml_fences(yaml_draft)`
into state with no non-empty check. Since the schema permitted an empty
yaml_draft (and told the model it was valid), an empty response flowed
straight through, and the validator turned it into the recurring error
"No YAML draft to validate." The router then looped back to the
generator, which fed that non-actionable error back to the LLM and
re-emitted empty. Because the planner resets retry_count on replan, the
identical cycle restarted — most often after a declined write, since the
writer clears the draft on deny.
Now an empty/whitespace draft (including the fence-stripping case)
escalates to replan instead of being committed, breaking the loop. Also
stop the schema description from instructing the model to return an
empty string.
Persist assistant.update messages into state (prefixed with their node)
during the run, then at successful completion summarize them via one LLM
invoke and attach the recap as a `summary` field inside run.completed.
On any summarizer failure, degrade to summary=null so the run still
completes (the file is already written).

- State: add assistant_updates accumulator (operator.add reducer)
- Planner/generator: write prefixed public_update deltas
- New services/run_summary module (mirrors services/compaction)
- Writer: calls summarize_run, threads summary into emit_run_completed
- Integrate `jsonschema` library for structural validation.
- Bundle the `gitlab-ci-schema.json` schema file locally.
- Update GitLab CI linting logic to run schema validation and format/report errors.
- Include unit/integration tests covering validation failures like wrong data types and typos.
This commit introduces a dedicated web research workflow, allowing the
agent to securely fetch current and external information (e.g., latest
package versions, external API syntax, provider documentation) during
the planning and generation phases.

Key additions:
- **Web Tools**: Added `websearch_tool` (DuckDuckGo integration) and
  `webfetch_tool` (URL content extraction with HTML-to-Markdown parsing).
  Includes robust error handling and graceful degradation for rate limits.
- **Researcher Subagent**: Created `researcher.py`, a ReAct agent sibling
  to the Analyzer. It is strictly equipped with read-only web tools, ensuring
  safe external data gathering without requiring HITL permission prompts.
- **Graph & State Integration**: Added `researcher_query` and
  `researcher_result` to the core state schema. Updated `supervisor.py`
  to natively orchestrate the new researcher node in the graph loop.
- **Structured LLM Handoff**: Updated Planner and Generator Pydantic
  schemas with `needs_web_research` and `researcher_query` fields. These
  nodes can now dynamically dispatch the Researcher when they detect gaps in
  their knowledge or when the Analyzer confirms information is external.
- **Streaming & Resilience**: The Researcher streams its `thinking` and
  `tool_call` events natively to the frontend. Inner loops are protected by
  Tenacity retries to survive flaky search APIs.
- **Prompt Engineering**: Updated Planner, Generator, and Analyzer system
  prompts to strictly forbid hallucinating versions/facts, enforcing a
  "when in doubt, research it" policy.

This architectural enhancement allows the agent to self-correct and stay
up-to-date with external facts without bloating the main context window.
Completely removed the orphaned `mcp_fetch` tool directory. This
heavyweight subprocess server is no longer needed since we
migrated to the native, faster `webfetch_tool` for web browsing.
Deletes the text truncation logic in `redaction.py` (which previously clipped important outputs like YAML drafts and model reasoning) while keeping secret redaction and list item capping intact. Updates unit tests accordingly.
Updates the description of the `max_results` parameter in the websearch tool input schema. Provides explicit guidelines for the LLM on adjusting the number of results (from 1 to 30) depending on query intent (e.g., factual lookup vs. broader research), while keeping the default at 5.
…ext preservation

Removes the arbitrary "2-4 sentence" cap on the `public_update` field across the planner and generator schemas and prompts. Encourages the LLM to provide detailed, thorough updates where necessary, preserving crucial reasoning context in the chat history (especially for models without native thinking/reasoning channels).
The webfetch tool was the only tool missing a tool_run context manager,
so its executions produced no tool.started/tool.completed/tool.failed
events. The researcher agent uses webfetch, meaning users had no
indication when the agent was fetching web content.

Wrap _run in tool_run("webfetch", ...) following the same pattern as
websearch, bash, glob, grep, list, read, and write tools.

Also fix a pre-existing flaky integration test in test_planner.py where
guards only checked analyzer_query before asserting replan bookkeeping.
The planner has three early-exit branches (analyzer, researcher,
clarification) that intentionally skip replan bookkeeping — only
producing a plan clears replan_requested and increments replan_count.
Update all guards to also check researcher_query and pending_question.
The redaction layer's high-entropy value scanner was flagging UUID tool
IDs as secrets ~54% of the time, replacing them with [REDACTED]. This
made every tool.started and tool.completed share the same id, so the
frontend could not match started events to their completion events and
rendered duplicate tool cards.

Add id and all structural event fields (tool, label, source, filepath,
duration_ms, etc.) to _PUBLIC_IDENTIFIER_KEYS so they bypass the
entropy scan. Sensitive keys (api_key, password, token, etc.) remain
redacted by key-name matching.
@MegumiinUwU
MegumiinUwU merged commit d7b3fe6 into main Jul 2, 2026
1 check passed
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