### Bugfixes — Agent Chat 'Думаю' State Leak - fix(agent-chat): loadHistory() now resets streamingState/idle + cancels stale submission — prevents 'Думаю' state leak across conversation switches - fix(agent-chat): onDisconnected/onDisconnectedPermanent cascade to streamingState — prevents permanent hang on connection loss during stream - fix(agent-chat): guard on isLoadingHistory — prevents false commit of 'agent unavailable' fallback when switching conversations - fix(agent-chat): remove race in _sendNow empty-response check vs Svelte microtask (duplicate logic removed, handles correctly) - fix(stream-processor): confirm_resolved now appends msg.text to partialText instead of dropping it ### Bugfixes — Backend PDF Upload - fix(document-parser): _detect_format_by_magic() — reads file header magic bytes as fallback when Gradio loses filename - fix(document-parser): improved name extraction — tries orig_name, path stem - fix(document-parser): @RELATION AgentChatTypes -> AgentChat.Types ### HITL Flow & Agent Chat Improvements - feat(agent): HITL resume confirm/deny with userId/userJwt/envId propagation - feat(agent): confirm_required metadata fallback via aget_state() after 'Event loop is closed' error during interrupt - feat(agent): interrupt_before re-enabled via AGENT_CONFIRM_TOOLS env var - feat(frontend): debug panel with connection/stream state monitoring - feat(frontend): AgentChatModel constructor options + onBeforeSend callback - feat(frontend): crypto.randomUUID() for local conversation ID on first send ### Backend Agent Refactoring - refactor(agent): langgraph_setup — monkey-patch for PydanticSerializationError - refactor(agent): tools.py — dual identity headers, expanded tool set - refactor(agent): run.py — _find_free_port, Gradio server port fallback - refactor(agent): app.py — file size validation, message truncation, HITL path ### Frontend - feat(dashboard-hub): DashboardHubModel with filters, pagination, git actions - feat(ui): DateRangeFilter component - feat(i18n): new dashboard keys; cache tooltips fix - fix(i18n): full run tooltips — cache is NOT ignored ### Semantic Protocol - chore(agents): update all agents with canonical format - chore(skills): sync semantics-core, semantics-contracts, molecular-cot-logging ### Housekeeping - chore: remove stale semantic reports (10 files, Jan 2026) - chore: update 033-gradio-agent-chat specs, contracts, UX, tasks, tests - chore: add .agents/ directory (mirrors .opencode/ agent layouts) - chore: update run.sh with DEV_MODE, port management
5.7 KiB
5.7 KiB
#region Traceability [C:3] [TYPE ADR] [SEMANTICS traceability,rtm,agent-chat] @defgroup Trace Matrix Requirements → Model → API → Fixture → Task → Test for Gradio Agent Chat.
Traceability Matrix
| Story | Screen | Model | Fixture | API Endpoint | Backend Task | Frontend Task | Test |
|---|---|---|---|---|---|---|---|
| US1: Streaming Chat | AssistantChatPanel | AgentChat.Model | FX_AgentChat.Model.SendMessage.Valid | submit("/chat") |
T015, T017 | T018, T019 | Test.AgentChat.Model |
| US1: Cancel | AssistantChatPanel | AgentChat.Model | FX_AgentChat.Model.CancelGeneration | submission.cancel() |
— | T020 | Test.AgentChat.Model |
| US1: Reconnect | AssistantChatPanel | AgentChat.Model | — | Client.connect() |
— | T022 | Test.AgentChat.Model |
| US2: Tool Selection | /agent |
AgentChat.Tools | — | FastAPI REST via native @tool |
T026, T028, T097 | T031 | Test.AgentChat.Tools |
| US2: Tool Context Budget | /agent |
AgentChat.Tools | — | get_tools_for_query() before create_agent() |
T098, T099 | — | Test.AgentChat.Tools |
| US2: HITL Confirm | /agent |
AgentChat.Model | FX_AgentChat.Model.ResumeConfirm | submit("/chat",...,[convId,"confirm"]) |
T029, T100 | T031 | Test.AgentChat.Model |
| US2: HITL Deny | /agent |
AgentChat.Model | FX_AgentChat.Model.ResumeDeny | submit("/chat",...,[convId,"deny"]) |
T029, T100 | T031 | Test.AgentChat.Model |
| US3: Tool Visibility | AssistantChatPanel | AgentChat.Model | — | — | — | T040, T041 | Test.AgentChat.ToolCallCard |
| US4: Context | /agent |
AgentChat.LangGraph | — | thread_id=conversation_id + PostgreSQL persistence/checkpoints |
T045 | — | Test.AgentChat.LangGraph |
| US5: List Conversations | ConversationList | AgentChat.Model | FX_AgentChat.Conversations.ListValid | GET /api/assistant/conversations |
T052, T053 | T059 | Test.AgentChat.Api |
| US5: List Empty | ConversationList | AgentChat.Model | FX_AgentChat.Conversations.ListEmpty | GET /api/assistant/conversations |
T052 | T059 | Test.AgentChat.Api |
| US5: Load History | AssistantChatPanel | AgentChat.Model | FX_AgentChat.History.Valid | GET /api/assistant/history |
T054 | T019 | Test.AgentChat.Api |
| US5: Delete/Archive | ConversationList | AgentChat.Model | FX_AgentChat.Delete.Valid | DELETE /api/assistant/conversations/{id} |
T055 | T058 | Test.AgentChat.Api |
| US5: Delete Not Owner | ConversationList | — | FX_AgentChat.Delete.NotOwner | DELETE /api/assistant/conversations/{id} |
T055 | — | Test.AgentChat.Api |
| US6: File Upload | AssistantChatPanel | AgentChat.Model | FX_AgentChat.Document.ParsePdf.Valid | submit("/chat", {text, files}) |
T065, T066 | T068, T069 | Test.AgentChat.Document |
| US6: PDF Encrypted | — | AgentChat.Document | FX_AgentChat.Document.ParsePdf.Encrypted | — | T065 | — | Test.AgentChat.Document |
| US6: XLSX Password | — | AgentChat.Document | FX_AgentChat.Document.ParseXlsx.PasswordProtected | — | T065 | — | Test.AgentChat.Document |
| —: Debug Info | /agent |
AgentChat.Model | — | UI-derived state | T101 | T073 | Browser snapshot |
| —: DEV Mode Transport | /agent |
AgentChat.GradioApp | — | /api/agent/gradio same-origin proxy |
T102 | T073 | Browser snapshot + run tests |
| —: Service Auth | — | — | FX_AgentChat.ServiceToken.Valid | POST /api/auth/service-token |
T080 | — | Test.AgentChat.Api |
| —: Rejected Paths | — | AgentChat.Model | FX_AgentChat.Model.RejectedPath | — | — | — | Test.AgentChat.Model.RejectedPaths |
Impact Analysis Quick Reference
| If you change... | These fixtures verify it | These tests verify it | These screens depend |
|---|---|---|---|
AgentChat.Model.sendMessage() |
FX_AgentChat.Model.SendMessage.Valid, ResumeConfirm, ResumeDeny, CancelGeneration | Test.AgentChat.Model | AssistantChatPanel, /agent |
POST /api/assistant/conversations |
FX_AgentChat.Conversations.ListValid, ListEmpty | Test.AgentChat.Api | ConversationList, AssistantChatPanel |
GET /api/assistant/history |
FX_AgentChat.History.Valid, NotFound | Test.AgentChat.Api | AssistantChatPanel |
DELETE /api/assistant/conversations/{id} |
FX_AgentChat.Delete.Valid, NotOwner, NotFound | Test.AgentChat.Api | ConversationList |
@tool functions in tools.py |
— | Test.AgentChat.Tools | Gradio agent handler |
get_tools_for_query() context-budget behavior |
— | Test.AgentChat.Tools / Test.AgentChat.Handler | Gradio agent handler |
| Document parser | FX_AgentChat.Document.ParsePdf.Valid, ParseXlsx.Valid | Test.AgentChat.Document | Gradio agent handler |
@gradio/client transport |
FX_AgentChat.Model.RejectedPath (WebSocket guardrail) | Test.AgentChat.Model.RejectedPaths | AssistantChatPanel |
POST /api/auth/service-token |
FX_AgentChat.ServiceToken.Valid, InvalidSecret | Test.AgentChat.Api | Gradio container startup |
Fixture Count
| Category | Count |
|---|---|
| API fixtures | 14 |
| Model fixtures | 5 |
| Total | 19 |
Current Verification Snapshot (2026-06-29)
| Slice | Command | Result |
|---|---|---|
| Backend agent | AUTH_SECRET_KEY=test-secret-key-for-agent-run-tests backend/.venv/bin/python -m pytest backend/tests/test_agent/test_agent_handler.py backend/tests/test_agent/test_langchain_tools.py backend/tests/test_agent/test_langgraph_setup.py backend/tests/test_agent/test_run.py |
46 passed, 5 warnings |
| Frontend model | cd frontend && npm run test -- src/lib/models/__tests__/AgentChatModel.test.ts --run |
73 passed |
| Frontend build | cd frontend && npm run build |
Passed; existing unrelated Svelte warnings |
#endregion Traceability