Skip to content

Add agent intelligence analysis layer#10

Merged
magic-alt merged 2 commits into
mainfrom
feat/agent-intelligence
May 22, 2026
Merged

Add agent intelligence analysis layer#10
magic-alt merged 2 commits into
mainfrom
feat/agent-intelligence

Conversation

@magic-alt
Copy link
Copy Markdown
Owner

Summary

  • add a second-pass agent intelligence pipeline with analysis context building, deep analysis execution, Hermes adapter boundaries, and OpenAI-compatible provider hooks for OpenAI, DeepSeek, and Ollama
  • expose new backend capabilities and document APIs for deep analysis and agent runs, and persist analysis artifacts for runtime inspection
  • add the web 智能洞察 experience, including capability badges, deep-analysis findings, run records, and the PdfViewer guard that prevents evidence jumps from auto-loading a broken iframe before the PDF blob is requested

Validation

  • npm run typecheck
  • rebuilt Docker and uploaded examples/real_pdf_analysis/fixtures/FY24_Q4_Consolidated_Financial_Statements.pdf
  • verified GET /v1/agent/capabilities, GET /v1/documents/{doc_id}/deep-analysis, and GET /v1/documents/{doc_id}/agent-runs
  • verified persisted artifacts in Postgres: extracted/analysis_context.json, extracted/deep_analysis.json, extracted/agent_runs.json
  • verified the 智能洞察 tab renders in the web UI after analysis completes

Notes

  • rebased onto the latest main after PR9 was merged and resolved the resulting conflict in web/src/api/types.ts

Copilot AI review requested due to automatic review settings May 22, 2026 00:39
@magic-alt magic-alt merged commit afc2fea into main May 22, 2026
5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an “agent intelligence” second-pass analysis layer to the existing PDF financial-report pipeline, exposing new backend endpoints/artifacts and a corresponding web UI tab for inspecting deep-analysis findings and agent run records.

Changes:

  • Backend: introduce analysis-context building + deep-analysis execution (Hermes adapter or OpenAI-compatible providers), persist artifacts, and expose new API endpoints.
  • Frontend: add “智能洞察” tab to display capabilities, deep-analysis findings, and agent run history; harden PDF viewer to avoid broken iframe loads before blob fetch.
  • Tests: cover new API endpoints, pipeline artifact persistence, deep-analysis normalization, and LLM provider routing.

Reviewed changes

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

Show a summary per file
File Description
web/src/views/DocumentDashboard.vue Loads capabilities/deep-analysis/run records and adds the “智能洞察” tab.
web/src/components/PdfViewer.vue Guards src so the iframe isn’t created until an object URL exists.
web/src/components/AgentInsightsPanel.vue New UI panel rendering capability badges, findings, run records, and limitations.
web/src/components/AgentInsightsPanel.spec.ts Unit test coverage for the new insights panel rendering.
web/src/api/types.ts Adds agent/deep-analysis related API types and SourceRef.confidence.
web/src/api/docs.ts Adds capabilities/deep-analysis/agent-runs API calls and deep-analysis normalization helpers.
web/src/api/docs.spec.ts Tests deep-analysis normalization, including evidence confidence handling.
tests/test_routes_web.py Exercises new /v1/agent/capabilities, /deep-analysis, and /agent-runs routes.
tests/test_pipeline_mock.py Verifies analysis pipeline now persists new extracted artifacts.
tests/test_agent_intelligence.py Validates context builder behavior and deepseek/ollama model config parsing.
src/tasks/analysis.py Persists partial analysis artifacts (context, deep analysis, agent runs).
src/schemas/models.py Adds Pydantic models for capabilities, context, runs, and deep-analysis results.
src/prompts/deep_analysis_prompt.md Introduces the deep-analysis prompt contract (JSON-only, evidence-backed).
src/llm/token_manager.py Adds context window defaults for DeepSeek/Qwen/Llama model name matching.
src/llm/openai_client.py Adds base_url support for OpenAI-compatible endpoints (DeepSeek/Ollama).
src/llm/mock.py Extends mock LLM to return deterministic DeepAnalysisResult outputs.
src/llm/base.py Adds provider base-url/api-key plumbing, deep-analysis routing, and config helpers.
src/api/routes.py Adds capability listing + deep-analysis/agent-runs read endpoints.
src/agent/state.py Extends agent state with analysis context, deep analysis, and agent run tracking.
src/agent/nodes.py Adds context-building node, deep-analysis execution (Hermes/LLM), and persistence/report integration.
src/agent/graph.py Inserts context + deep-analysis nodes into the main graph sequence.
src/agent/context.py Implements token-budgeted analysis-context construction with RAG-backed retrieval.
src/agent/capabilities.py Defines runtime-reported agent capabilities based on provider configuration.
src/agent/adapters/hermes.py Implements Hermes HTTP adapter for deep-analysis execution.
src/agent/adapters/base.py Defines the external agent client protocol boundary.
src/agent/adapters/init.py Initializes the adapters package.
.env.example Documents new env vars for deep-analysis routing, provider base URLs, and Hermes adapter config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web/src/api/docs.ts
Comment on lines +129 to +140
function normalizeFinding(raw: any, index: number): AnalysisFinding {
return {
finding_id: raw?.finding_id || raw?.id || `finding-${index + 1}`,
category: raw?.category || 'other',
title: raw?.title || raw?.summary || 'Untitled finding',
severity: raw?.severity || 'low',
summary: raw?.summary || raw?.description || '',
detail: raw?.detail ?? null,
metrics: raw?.metrics && typeof raw.metrics === 'object' ? raw.metrics : {},
evidence: Array.isArray(raw?.evidence) ? raw.evidence.map(normalizeSourceRef) : [],
confidence: typeof raw?.confidence === 'number' ? raw.confidence : undefined,
}
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