Add agent intelligence analysis layer#10
Merged
Conversation
There was a problem hiding this comment.
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 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, | ||
| } |
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
智能洞察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 requestedValidation
npm run typecheckexamples/real_pdf_analysis/fixtures/FY24_Q4_Consolidated_Financial_Statements.pdfGET /v1/agent/capabilities,GET /v1/documents/{doc_id}/deep-analysis, andGET /v1/documents/{doc_id}/agent-runsextracted/analysis_context.json,extracted/deep_analysis.json,extracted/agent_runs.json智能洞察tab renders in the web UI after analysis completesNotes
mainafter PR9 was merged and resolved the resulting conflict inweb/src/api/types.ts