salesforce-agentforce-cookbook poller. This page walks through Salesforce setup and what you will see in HoneyHive.
The Session Trace OTel API is in beta. The cookbook includes a poller you can run as written.
Prerequisites
- Salesforce org with Agentforce and Data 360 (Developer Edition works)
- Agentforce Session Tracing and Audit and Feedback enabled
- An External Client App (ECA) for OAuth
- Python 3.10+ with
uvorpipto installrequirements.txt(python-dotenv,requests) - A HoneyHive project API key from Settings > Project > API Keys
How it works
- Agentforce writes turns, LLM calls, and actions into Data 360.
- The poller discovers recent session IDs and fetches each session from Salesforce’s Session Trace OTel API.
- It stamps public session attributes, rewrites Salesforce I/O onto GenAI JSON strings, then POSTs the OTLP JSON to HoneyHive.
- Run it once, or keep it looping on a schedule.
Enable tracing in Salesforce
1
Turn on Data 360
Turn on Data 360 from Setup > Data Cloud Setup Home and wait until it shows as live.
2
Confirm the Einstein Audit dataspace
Open Setup > Einstein Audit, Analytics, and Monitoring Setup. Confirm a dataspace is selected (often
default). Without this, the OTel API returns No selected dataspace for Einstein Audit.3
Turn on the tracing toggles
Turn on:
- Agentforce Session Tracing (data model provisioning can take about 10 minutes; see Export Agentforce Session Tracing Data)
- Audit and Feedback (Salesforce may take a few hours before data appears; see Set Up Einstein Generative AI Audit and Feedback)
- Agent Platform Tracing if listed
4
Refresh the Agentforce data streams
In Data Cloud > Data Streams, make sure the Agentforce streams are Active:
AiAgentSession, AiAgentInteraction, AiAgentInteractionMessage, and AiAgentInteractionStep. Run a refresh on each. Until you do, session rows can exist in Data 360 while the OTel API still returns 404 for those sessions.5
Activate the agent
Activate (publish) the agent. Draft-only preview sessions often do not show up in Session Tracing.
Create an External Client App
In Setup > External Client Apps (or App Manager):1
Select the API scope
For client credentials, select Manage user data via APIs (
api). Using only Full access (full) can fail with invalid_grant: no valid scopes defined.2
Enable Client Credentials Flow
Enable Client Credentials Flow and set Run As to a user with Data Cloud access and Einstein Audit read access (Setup > Einstein Audit, Analytics, and Monitoring Setup, the same screen as Enable tracing in Salesforce step 2). These are separate permissions: a user with only Data Cloud access passes discovery and then fails every OTel fetch with
403 INSUFFICIENT_ACCESS.3
Copy the credentials
Copy the consumer key and secret into env vars. Do not commit them. Viewing consumer details may require email verification. Copy the My Domain login host (
https://<domain>.my.salesforce.com) into SALESFORCE_INSTANCE_URL, not the Lightning host or an Experience Cloud domain.Run the poller
Clone the cookbook, installrequirements.txt, copy poller.env.example to poller.env, and fill in your HoneyHive key, data plane URL, My Domain host, and External Client App credentials. The script loads poller.env from this directory.
Have at least one finished conversation with the activated agent, then:
What HoneyHive receives
One Agentforce conversation becomes one HoneyHive session. Open Traces > Sessions and find the session named after your agent. HoneyHive uses a derived session UUID. Reusing the Salesforce session id opens a child turn instead of the conversation. Salesforce Session Trace exports the full Agentforce graph, not only the user and assistant turns. A typical conversation has these events:
Names like
off_topic and GeneralFAQ are Salesforce topic names, not HoneyHive features.
Salesforce stores turn text on agent.messages.* keys and step I/O in a kvlist. The poller rewrites those onto gen_ai.input.messages and gen_ai.output.messages. It also stamps gen_ai.operation.name (chat, invoke_agent, execute_tool) so HoneyHive classifies the tree. See Framework Attribute Mapping.
A typical session looks like this:

An exported Agentforce session in HoneyHive Traces. The tree shows topic turns such as GeneralFAQ with router, guardrail, and instruction-adherence children. The selected turn shows the user and assistant messages.
If the export looks wrong
If a session is missing, confirm the poller POSTed to{HH_API_URL}/opentelemetry/v1/traces and that the API key belongs to this project.
Related
Cookbook source
Poller source
Tracing introduction
Sessions, event types, and trace hierarchy in HoneyHive