WeKnora/internal
wizardchen a6d4266c93 fix(agent): terminate ReAct loop on final_answer regardless of arg parse success
The agent loop previously kept running when the LLM emitted final_answer with
malformed JSON arguments: observe.analyzeResponse strictly json.Unmarshal'd the
raw args and returned isDone=false on failure, while act.runToolCall separately
repaired the JSON and executed the tool. The mismatch made final_answer
non-terminal, so the LLM saw its own answer in the next round's tool result
and re-emitted final_answer, surfacing near-identical answers multiple times
to the user (issue #1008).

Fix by unifying parsing in a new tools.ParseFinalAnswerArgs helper with three
fallbacks (strict -> RepairJSON -> regex extraction) and making final_answer
always terminal in analyzeResponse. When no answer can be recovered, emit a
user-visible fallback message and a Done=true event so the UI still resolves.

Also route final_answer.Execute through the same helper so tool execution and
loop termination stay consistent.

Adds regression tests in observe_test.go and final_answer_test.go covering
valid args, RepairJSON recovery, unrecoverable args, and garbage input.

Refs: Tencent/WeKnora#1008
2026-04-23 19:36:28 +08:00
..
agent fix(agent): terminate ReAct loop on final_answer regardless of arg parse success 2026-04-23 19:36:28 +08:00
application feat: Enhance agent tool compatibility and knowledge base filtering 2026-04-23 17:28:00 +08:00
assets feat(assets): add ASR test audio file and embed it in the application 2026-04-02 21:27:27 +08:00
common feat: Implement deadlock retry mechanism for chunk creation 2026-04-22 21:17:21 +08:00
config feat: Introduce agent type presets for smart-reasoning mode 2026-04-22 21:18:20 +08:00
container feat: Implement comprehensive wiki feature for knowledge bases 2026-04-22 21:17:18 +08:00
database fix: update environment configuration for debugging and logging, enhance SQLite FTS5 table management, and improve API base URL handling 2026-04-11 18:51:16 +08:00
datasource fix: improve tenant access token logging and update test cases 2026-04-22 21:17:30 +08:00
errors feat: Add agent configuration and cleanup scripts for database migrations 2025-11-05 23:18:44 +08:00
event fix: improve tenant access token logging and update test cases 2026-04-22 21:17:30 +08:00
handler feat: Enhance agent tool compatibility and knowledge base filtering 2026-04-23 17:28:00 +08:00
im fix : mattermost handle io.ReadAll errors in client file 2026-04-23 17:51:07 +08:00
infrastructure feat: Add pending tasks and active status to WikiStats 2026-04-22 21:17:31 +08:00
logger feat(datasource): add Yuque (语雀) connector 2026-04-22 16:39:55 +08:00
mcp feat(mcp): implement reconnection logic for MCP tool calls and tool listing 2026-03-31 11:57:15 +08:00
middleware refactor: Update wiki prompts and ingestion logic for improved content handling 2026-04-22 21:17:31 +08:00
models refactor: Simplify WeKnoraCloud request customization and message conversion 2026-04-23 17:52:43 +08:00
router feat: Refactor knowledge base service and router for improved wiki handling 2026-04-22 21:18:32 +08:00
runtime init commit 2025-08-05 15:08:07 +08:00
sandbox feat: optimize security and deployment of agent skills 2026-02-04 20:08:49 +08:00
searchutil feat(prompt): enhance question rewriting and intent classification in prompt templates 2026-04-16 23:15:02 +08:00
stream feat(redis): add REDIS_USERNAME support for Redis ACL 2026-02-04 19:38:40 +08:00
tracing init commit 2025-08-05 15:08:07 +08:00
types feat: Implement auto-linked content updates in wiki page management 2026-04-23 11:16:47 +08:00
utils fix: improve tenant access token logging and update test cases 2026-04-22 21:17:30 +08:00