#how do I log the llm prompt and context at each turn for an agent built with the platform? I'm deb
1 messages · Page 1 of 1 (latest)
Short answer: the platform does not expose the raw, fully‑assembled LLM prompt per turn. What you can log is (a) all turn‑by‑turn user/agent messages and tool calls in real time, and (b) the RAG context that was retrieved for each turn via conversation history/webhooks. If you need the exact prompt payload that the LLM received, use a Custom LLM and log the incoming chat‑completion request on your server.
What to log and where to get it
- Live, per turn:
- Subscribe to the WebSocket events and log:
- user_transcript (finalized ASR text)
- agent_response (final agent message)
- client_tool_call and agent_tool_response (function/tool use)
- contextual_update you send (UI or app context; these are recorded in history as tool calls) (elevenlabs.io)
- Subscribe to the WebSocket events and log:
- After the call (for RAG/debugging):
- Get conversation history: GET /v1/convai/conversations/:conversation_id returns transcript, metadata, analysis, and initiation client data; the endpoint was updated to include RAG information for retrieved KB content. (elevenlabs.io)
- The dashboard history view also shows “retrieved chunks by RAG” per call (useful for correlating what context was fed to the LLM). (elevenlabs.io)
- Or enable post_call_transcription webhooks to receive the same conversation object automatically when analysis completes (same structure as GET Conversation). (elevenlabs.io)
About logging “the prompt”
- There is no documented API/setting to return the exact compiled LLM prompt per turn (system prompt + dynamic vars + RAG context + tool traces). This is not shown in the Events or Conversations schemas. (elevenlabs.io)
- If you must see the exact payload the LLM receives, integrate a Custom LLM (OpenAI‑compatible chat completions). Your server will receive the full messages/tools payload for each turn, which you can log before responding. (elevenlabs.io)
References
- Agent WebSockets (event types and examples): user_transcript, agent_response, client_tool_call, contextual_update. (elevenlabs.io)
- Conversations API: list/get conversation; GET was updated to include RAG info. (elevenlabs.io)
- Changelog: RAG chunks visible in history view. (elevenlabs.io)
- Post‑call webhooks: delivers the conversation (same model as GET Conversation). (elevenlabs.io)
- Custom LLM integration (log the incoming request to capture the exact prompt/context). (elevenlabs.io)
If you want, I can sketch a minimal logger that:
- writes WebSocket events to disk during the call, and
- upserts the final GET Conversation (including RAG fields) when the call ends. (elevenlabs.io
ok so I do see the document and chunk IDs. how can I look them up?
You can resolve those IDs via the Knowledge Base API:
- Get a document (metadata): GET /v1/convai/knowledge-base/:documentation_id. (elevenlabs.io)
- Stream the full document content: GET /v1/convai/knowledge-base/:documentation_id/content. (elevenlabs.io)
- Get a specific RAG chunk by ID: GET /v1/convai/knowledge-base/:documentation_id/chunk/:chunk_id. (elevenlabs.io)
- Optionally, list documents to find names/IDs: GET /v1/convai/knowledge-base. (elevenlabs.io)
All endpoints require the xi-api-key header.
FYI: conversation details now include RAG information so you can trace which chunks were used in a turn; check the Conversations “Get” endpoint along with the March 24, 2025 changelog note. (elevenlabs.io)
UI: you can also review retrieved chunks in the History view (as noted in the changelog) and manage documents in the Knowledge Base dashboard. (elevenlabs.io)
Sources:
Get knowledge base document | ElevenLabs Documentation
Get document content | ElevenLabs Documentation
Get document chunk | ElevenLabs Documentation
List knowledge base documents | ElevenLabs Documentation
Get conversation details | ElevenLabs Documentation
March 17, 2025 | ElevenLabs Documentation
how do I view all chunks of a document?
Short answer: there’s no API to list all chunks of a knowledge‑base document today.
What you can do instead:
- View the full, raw content of the document: GET /v1/convai/knowledge-base/:documentation_id/content. (elevenlabs.io)
- If you already have chunk IDs (e.g., from conversation logs), fetch any specific chunk: GET /v1/convai/knowledge-base/:documentation_id/chunk/:chunk_id. (elevenlabs.io)
- To discover which chunks were actually retrieved during a call, use the conversation details (RAG retrieval info was added to this endpoint) or view the History UI, which shows retrieved RAG chunks. (elevenlabs.io)
- In the dashboard, you can open a knowledge‑base document and view its entire content (large RAG document viewing was added on Mar 24, 2025). (elevenlabs.io)
If you need a complete chunk inventory for a document (not just the ones used in a call), the docs don’t expose that yet; the closest workaround is to stream the full content and handle your own chunking offline. (elevenlabs.io)
Sources:
Get document content | ElevenLabs Documentation
Get document chunk | ElevenLabs Documentation
March 24, 2025 | ElevenLabs Documentation
March 24, 2025 | ElevenLabs Documentation
Get document content | ElevenLabs Documentation
I see chunks from a document I thought I removed from my agent. the knowledgebase also shows it's being used. but the agent details don't show it. what's going on?
Short answer: the document is still attached to at least one agent in your workspace, so RAG can still retrieve its chunks. The “Agents” tab on the document shows dependencies across all agents, while an individual agent’s details only show what that one agent includes.
How to verify and fix:
- Check dependencies in the dashboard: open the document in Knowledge Base and look at its “Agents” tab. You can’t delete a doc while any agent depends on it. (elevenlabs.io)
- Or query via API: GET /v1/convai/knowledge-base/:documentation_id/dependent-agents to list every agent that still references the document. Remove it from those agents. (elevenlabs.io)
- Confirm what was retrieved: conversation history now shows “RAG chunks” that were used; ensure you’re looking at a conversation started after you removed the doc, not an older one. (elevenlabs.io)
- If you must purge the document even though agents still depend on it, the Delete Knowledge Base Document endpoint supports a force=true parameter (added June 1, 2025). Use with care, since dependent agents will then lose access. (elevenlabs.io)
Related: documents can be reused across multiple agents, and usage mode (“Auto” vs “Prompt”) affects when chunks are retrieved once a doc is attached—double‑check the usage mode after you identify the dependent agent(s). (elevenlabs.io)
Sources:
Knowledge base dashboard | ElevenLabs Documentation
Get dependent agents | ElevenLabs Documentation
March 17, 2025 | ElevenLabs Documentation
June 1, 2025 | ElevenLabs Documentation
Retrieval-Augmented Generation | ElevenLabs Documentation
what does it mean "Fix knowledge base errors to proceed" in the ux when I add a doc to my agent? I can't save the agent after I add it as I just get that error. the diff just includes my new file: "id": "3qBvncvPM7OzQyf6djkt",
"name": "Acts Context.docx",
"usage_mode": "auto"
},