#488

feat(tools): add knowledge_search over the shared knowledge base

Openlimin1975wants to merge intofrom

Summary

Adds a knowledge_search tool that lets the assistant query the shared/manual knowledge base (documents flagged Manual=true) via natural language. This complements the per-agent RAG retriever (which now excludes Manual docs), so operators can publish curated knowledge that is only reachable through an explicit tool call instead of being silently mixed into every agent turn.

Changes

  • pkg/tools/knowledge_search.go: new tool calling KnowledgeStore.SearchDocuments, scoped to Manual=true.
  • pkg/tools/search.go: exclude Manual=true docs from the generic retriever.
  • pkg/tools/registry.go + tools.go: register the tool (only when everyService=true).
  • pkg/templates/... + providers/assistant.go: forced-retrieval rule + tool-name rendering.
  • pkg/providers/performer.go: callWithRetries accepts extraOpts ...llms.CallOption; keeps CallWithTools on the default path and switches to CallWithExtraOptions only when extra options (e.g. a forced named tool_choice) are present.
  • pkg/database/knowledge/knowledge.go: define KnowledgePublisher locally to break the tools → knowledge → subscriptions → tools import cycle.
  • Env gate PENTAGI_ASSISTANT_FORCE_KBSEARCH (default off) forces the first assistant call to a named tool_choice for deterministic retrieval; verified disabled in production.
  • docker-compose.yml + Dockerfile.ollama + .gitignore: optional local Ollama service for RAG embeddings.
  • push_to_fork.sh: one-shot helper to push to the fork over SSH port 443.

Why

Shared knowledge (deployment briefs, access keys, runbooks) should be explicitly retrievable and auditable, not injected into every agent context.

Testing

  • End-to-end: a running flow autonomously invoked knowledge_search and returned the correct curated document (relevance 0.8655).
  • pkg/tools/... and pkg/providers/... tests pass (two pre-existing upstream README/Graphiti baseline failures are unrelated).
  • Container rebuilt with CGO_ENABLED=0; API login returns 200.

Notes

The forced-tool_choice path is env-gated and disabled by default; production behavior is unchanged unless explicitly enabled.

Activity

7
limin19758h ago

Hi maintainers, thanks for taking a look at this PR!

Since it's opened from a fork, the CI workflows are currently awaiting approval (2 workflows). Could you please approve the workflows so they can run, and review the changes when you get a chance?

Quick recap:​ this adds a knowledge_search tool over the shared/manual knowledge base, plus an env-gated forced tool_choice path that is disabled by default (production behavior unchanged). All 6 commits are signed and show as Verified.

Happy to address any feedback — thanks!