WeKnora/internal/agent/tools
wizardchen 5d0326f987 fix(wiki): harden slug integrity across ingest and agent write paths
Weak LLMs routinely mangle high-entropy wiki slugs (especially UUID-based
summary/<id> slugs), producing dead cross-links and cross-item dedup
hallucinations. This tightens integrity end to end:

- Ingest dedup now groups each new item with only its own trigram
  candidates and validates merges against that per-item scope, rejecting
  cross-item mispairings; candidate top-K narrowed 20 -> 5.
- Editor path aliases out-link slugs behind low-entropy ref-N tokens and
  translates them back after generation, removing the chance to mangle.
- Agent write tool normalizes/validates slugs, blocks manual creation of
  system-owned summary pages, and auto-repairs dead [[slug]] links
  (rewrite-only, never strips) via bigram/display-text resolution.
- llmresource registry aliases summary/<uuid> slugs the same way as
  storage handles so they round-trip safely through chat.

Adds unit tests for slug validation, aliasing round-trip, dead-link
repair, and dedup rejection rules.
2026-07-24 15:57:08 +08:00
..
capabilities.go refactor(agent): remove final_answer tool references and update related logic 2026-06-04 15:48:04 +08:00
data_analysis.go feat(llm): introduce request-local source reference aliases 2026-07-17 10:19:43 +08:00
data_analysis_duckdb_test.go test(agent): add end-to-end DuckDB excel tests and fix sheet enumeration (#1007) 2026-04-24 19:57:56 +08:00
data_analysis_materialize_test.go fix: deep-copy stored files and images when cloning a knowledge base 2026-06-03 14:45:59 +08:00
data_analysis_test.go feat: data_analysis sql validation & type processing 2026-04-28 23:47:34 +08:00
data_schema.go feat(knowledge): enhance FAQ entry filtering and tagging 2026-07-23 10:50:32 +08:00
database_query.go fix(agent): enforce tag scopes across knowledge tools 2026-06-29 19:17:42 +08:00
definitions.go refactor(agent): remove final_answer tool references and update related logic 2026-06-04 15:48:04 +08:00
exec_context.go feat: scope API MCP OAuth by principal 2026-06-30 20:01:05 +08:00
faq_snippet.go feat(faq): enhance FAQ handling and localization support 2026-06-04 21:43:16 +08:00
faq_snippet_test.go feat(faq): enhance FAQ handling and localization support 2026-06-04 21:43:16 +08:00
get_document_info.go feat(knowledge): enhance FAQ entry filtering and tagging 2026-07-23 10:50:32 +08:00
grep_chunks.go feat(llm): introduce request-local source reference aliases 2026-07-17 10:19:43 +08:00
grep_chunks_aggregate_test.go feat(agent): add tool result persistence trimming for large outputs 2026-06-16 01:09:23 +08:00
grep_chunks_scope_test.go fix(agent): avoid expanding tag scopes for grep chunks 2026-06-29 19:17:42 +08:00
grep_chunks_snippet_test.go feat(faq): enhance FAQ handling and localization support 2026-06-04 21:43:16 +08:00
image_markdown_output_test.go fix(chat): use Markdown for LLM image context and normalize legacy XML 2026-07-15 18:10:31 +08:00
json_repair.go feat: Enhance agent retrieval strategies and regex handling 2026-04-22 21:18:21 +08:00
json_repair_test.go feat: Enhance agent retrieval strategies and regex handling 2026-04-22 21:18:21 +08:00
knowledge_search.go feat(llm): add prompt-cache observability and wiki cache-friendly prompts 2026-07-23 19:17:30 +08:00
knowledge_search_rerank_test.go feat(agent): enhance suggested questions API with tag scopes 2026-07-17 10:19:43 +08:00
list_knowledge_chunks.go feat(knowledge): enhance FAQ entry filtering and tagging 2026-07-23 10:50:32 +08:00
mcp_oauth.go fix(mcp): coordinate OAuth token refresh and authorization polling 2026-07-23 15:35:24 +08:00
mcp_tool.go feat(agent): add configurable MCP OAuth wait timeout per agent 2026-07-01 14:37:37 +08:00
mcp_tool_image_test.go feat: auto-describe MCP tool result images via VLM 2026-03-25 21:38:15 +08:00
mcp_tool_test.go feat(tests): add comprehensive tests for MCPTool functionality 2026-03-25 22:08:29 +08:00
normalize_id.go feat(agent): enhance tool execution and message sanitization 2026-03-25 22:08:29 +08:00
normalize_id_test.go feat(agent): enhance tool execution and message sanitization 2026-03-25 22:08:29 +08:00
param_cast.go fix(agent): harden tool parameter parsing against LLM type mismatches (#1505) 2026-05-28 07:50:26 +08:00
param_cast_test.go refactor(prompt): streamline context handling in templates 2026-03-25 22:08:29 +08:00
param_validate.go feat(agent): implement memory consolidation and context management 2026-03-25 22:08:29 +08:00
param_validate_test.go feat(agent): implement memory consolidation and context management 2026-03-25 22:08:29 +08:00
persist.go feat(chat): add session-scoped temporary attachments with async parsing 2026-07-16 17:41:27 +08:00
persist_test.go feat(agent): add tool result persistence trimming for large outputs 2026-06-16 01:09:23 +08:00
query_knowledge_graph.go feat(llm): introduce request-local source reference aliases 2026-07-17 10:19:43 +08:00
query_knowledge_graph_test.go Simplify KB duplicate API and improve naming/docs coverage. 2026-07-08 20:55:54 +08:00
registry.go fix(agent/tools): sort function definitions for deterministic ordering 2026-05-25 16:47:14 +08:00
registry_test.go fix(agent/tools): sort function definitions for deterministic ordering 2026-05-25 16:47:14 +08:00
sanitize_messages.go feat(agent): enhance tool execution and message sanitization 2026-03-25 22:08:29 +08:00
sanitize_messages_test.go feat(agent): enhance tool execution and message sanitization 2026-03-25 22:08:29 +08:00
scope_authorization.go fix(agent): enforce tag scopes across knowledge tools 2026-06-29 19:17:42 +08:00
scope_authorization_test.go fix(agent): enforce tag scopes across knowledge tools 2026-06-29 19:17:42 +08:00
sequentialthinking.go refactor(agent): remove final_answer tool references and update related logic 2026-06-04 15:48:04 +08:00
skill_execute.go feat: optimize security and deployment of agent skills 2026-02-04 20:08:49 +08:00
skill_read.go feat: support agent skills 2026-02-04 20:08:49 +08:00
strip_think.go refactor(agent): remove query display from DatabaseQuery component and update tool result structure 2026-03-25 22:08:29 +08:00
strip_think_test.go refactor(agent): remove query display from DatabaseQuery component and update tool result structure 2026-03-25 22:08:29 +08:00
think_stream.go feat(agent): enhance event routing for reasoning and answers in streaming 2026-06-04 15:48:04 +08:00
think_stream_test.go feat(agent): enhance event routing for reasoning and answers in streaming 2026-06-04 15:48:04 +08:00
todo_write.go fix(agent): harden tool parameter parsing against LLM type mismatches (#1505) 2026-05-28 07:50:26 +08:00
tool.go feat: use language-neutral English prompts for multilingual LLM responses 2026-03-06 21:08:12 +08:00
truncate.go feat(agent): implement memory consolidation and context management 2026-03-25 22:08:29 +08:00
truncate_test.go feat(agent): implement memory consolidation and context management 2026-03-25 22:08:29 +08:00
web_fetch.go feat(llm): add prompt-cache observability and wiki cache-friendly prompts 2026-07-23 19:17:30 +08:00
web_search.go feat(llm): introduce request-local source reference aliases 2026-07-17 10:19:43 +08:00
wiki_delete_page.go feat: Implement wiki editing functionalities and UI components 2026-04-22 21:18:08 +08:00
wiki_flag_issue.go feat(llm): introduce request-local source reference aliases 2026-07-17 10:19:43 +08:00
wiki_index_overview_test.go perf(wiki): move ingest log to event table and index to on-demand API 2026-05-08 21:48:52 +08:00
wiki_read_issue.go feat: Introduce Wiki Fixer agent and related functionalities 2026-04-22 21:18:08 +08:00
wiki_read_source_doc.go feat(knowledge): enhance FAQ entry filtering and tagging 2026-07-23 10:50:32 +08:00
wiki_rename_page.go feat: Implement wiki editing functionalities and UI components 2026-04-22 21:18:08 +08:00
wiki_replace_text.go feat(llm): introduce request-local source reference aliases 2026-07-17 10:19:43 +08:00
wiki_tools.go feat(llm): introduce request-local source reference aliases 2026-07-17 10:19:43 +08:00
wiki_tools_test.go feat: Add Wiki Researcher agent and system prompt for enhanced knowledge retrieval 2026-04-22 21:17:35 +08:00
wiki_update_issue.go feat: Introduce Wiki Fixer agent and related functionalities 2026-04-22 21:18:08 +08:00
wiki_write_page.go fix(wiki): harden slug integrity across ingest and agent write paths 2026-07-24 15:57:08 +08:00
wiki_write_page_test.go fix(wiki): harden slug integrity across ingest and agent write paths 2026-07-24 15:57:08 +08:00