feat(tools): add knowledge base search example#81
Open
xinghaohuang91 wants to merge 3 commits into
Open
Conversation
ryanrouleau
reviewed
Jul 10, 2026
| Feature: Knowledge Base Search Tool | ||
|
|
||
| Demonstrates TAC's knowledge tool letting an LLM agent answer questions by | ||
| searching a Twilio Knowledge Base. Works on voice and SMS. |
Collaborator
There was a problem hiding this comment.
nit: remove Works on voice and SMS.
makes it sound like knowledge only works on voice and sms instead of all channels
ryanrouleau
reviewed
Jul 10, 2026
| @@ -128,6 +130,7 @@ See `examples/.env.example` for all available configuration options. Key variabl | |||
|
|
|||
| ### Optional (Channel-Specific) | |||
Collaborator
There was a problem hiding this comment.
Let's remove (Channel-Specific) here now? Since the vars are not specific.
maybe (channel and feature specific) instead
ryanrouleau
reviewed
Jul 10, 2026
| "Install with: pip install openai-agents" | ||
| ) from e | ||
|
|
||
| def _json_default(obj: object) -> object: |
Add getting_started knowledge tool example (voice + SMS). Fix Agents SDK bridge to JSON-serialize Pydantic tool results (knowledge tool returned list[KnowledgeChunkResult], which crashed json.dumps), and add a debug log on tool invocation.
Use model_dump(mode="json") so Pydantic models returned by tools (e.g. knowledge base chunks) coerce non-primitive fields to JSON-encodable values before json.dumps.
- Drop 'Works on voice and SMS' from knowledge example docstring - Rename README env section from 'Optional (Channel-Specific)' to 'Optional'
xinghaohuang91
force-pushed
the
feat/knowledge-tool-example
branch
from
July 14, 2026 21:10
39dcf28 to
e5846ff
Compare
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
Adds a runnable knowledge base search example and fixes serialization bugs in the OpenAI Agents SDK tool bridge.
getting_started/examples/features/knowledge.py— an LLM agent that answers user questions by searching a Twilio Knowledge Base viacreate_knowledge_tool. Modeled on the existinghandoff.py.TACTool.to_openai_agents_sdk_tool()now JSON-serializes Pydantic tool results. The built-in knowledge tool returnslist[KnowledgeChunkResult], which the stdlibjson.dumpscouldn't encode — any tool returning Pydantic models crashed withObject of type ... is not JSON serializable.model_dump(mode="json")so models with non-primitive fields (datetime, UUID, Decimal) coerce to JSON-encodable values instead of crashing atjson.dumps. Covered by a new test.debuglog on tool invocation so tool calls are visible in logs.TWILIO_KNOWLEDGE_BASE_IDtogetting_started/README.mdand.env.example.Type of Change
Checklist
SDK Parity
The serialization fixes affect shared tool functionality and should be mirrored in the TypeScript SDK.
🤖 Generated with Claude Code