Skip to content

fix(templates): register the local Agentex tracing processor so the developer UI traces tab shows spans - #512

Open
michaelxu2288 wants to merge 2 commits into
scaleapi:mainfrom
michaelxu2288:fix/templates-local-tracing
Open

michaelxu2288 wants to merge 2 commits into
scaleapi:mainfrom
michaelxu2288:fix/templates-local-tracing

Conversation

@michaelxu2288

@michaelxu2288 michaelxu2288 commented Sep 10, 2026 •

Copy link
Copy Markdown

Problem

The README's quickstart ends with "Investigate your agent's behavior by opening the traces tab", but every agentex init framework template registers only SGPTracingProcessorConfig, which disables itself when SGP_API_KEY / SGP_ACCOUNT_ID are empty. No other code creates a tracing processor (TracingProcessorManager starts with an empty list), so the spans the unified harness derives are never written to the backend /spans API and the traces sidebar shows "No spans found for this task" for any locally scaffolded agent.

Repro: agentex init (Sync ACP + Claude Code, or any framework), run it against ./dev.sh, send a message, GET /spans?task_id=<task> -> [], backend log has no POST /spans.

Fix

Register AgentexTracingProcessorConfig() ahead of the SGP block in all 16 framework templates (sync / default / temporal x openai-agents, pydantic-ai, langgraph, claude-code, codex, plus the OpenAI local-sandbox variant). SGP registration is unchanged. Fixes a comment in sync-langgraph that claimed to register the Agentex processor while registering SGP. Adds a parametrized test in tests/lib/cli/test_init_templates.py asserting every framework template registers the local processor.

Verification

  • tests/lib/cli/test_init_templates.py: 42 passed (26 existing + 16 new).
  • All 19 templates rendered through create_project_structure and byte-compiled.
  • Fresh agent scaffolded from the patched sync-claude-code template against a local backend: message -> POST /spans, GET /spans?task_id=... returns the message (AGENT_WORKFLOW) span. Same for a temporal-claude-code agent (Turn 1/2/3 spans via the worker). Without the change: 0 spans.

Follow-ups (not in this PR)

  • 22 tutorial/demo files under examples/ register SGP only, and 00_sync/020_streaming (which the README tells users to copy) registers nothing; happy to mirror this change there.
  • Alternative that fixes everything at once: have the SDK auto-register the Agentex processor when AGENTEX_BASE_URL is set (idempotent, env kill-switch). That changes runtime behaviour for existing agents, so I kept this PR template-only; maintainers' call.

RetriggerConfidence Score: 3/5

This PR is not safe to merge until locally scaffolded agents send spans to the local backend when AGENTEX_BASE_URL is unset.

What we checked:

  • Disabled backend still exports spans: No. The template skips processor registration when the URL is an empty string.

Summary

Scaffolded agents now send spans to the local Agentex backend, and task/create waits until its workflow starts. The PR also updates the SDK’s production URL and changes release and CI workflows.

  • Adds local tracing registration to all 16 framework templates while keeping SGP tracing.
  • Makes task creation wait for its handler, while event sending stays asynchronous.
  • Updates the SDK’s production endpoint and adds repository release and CI automation.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Scaffolded agent with URL unset] --> B[Template enables tracing]
  B --> C[Processor creates Agentex]
  C --> D[Client selects production URL]
  D --> E[Span request goes to production]
Loading

Reviews (3) · Last reviewed commit: "fix(templates): skip the local tracing p..."

Comment thread src/agentex/lib/cli/templates/sync-claude-code/project/acp.py.j2 Outdated
@mohammadatallah-scale

Copy link
Copy Markdown

P1 This registers the Agentex tracing processor that #517 removes, and scaleapi/scale-agentex#430 deletes the server-side spans API it writes to, so whichever merges second leaves every scaffolded agent failing at import. The developer UI traces tab is served by #430's platform-backed reader instead, so this needs rebasing to the SGP processor only or closing as superseded.

@stainless-app
stainless-app Bot force-pushed the next branch 2 times, most recently from bc51c52 to 761833e Compare September 18, 2026 21:47
…eveloper UI traces tab shows spans

Every framework template registered only SGPTracingProcessorConfig, which
disables itself when SGP_API_KEY or SGP_ACCOUNT_ID is empty. Nothing else
creates a tracing processor, so spans derived by the unified harness were
never written to the backend /spans API and a scaffolded agent always showed
"No spans found for this task" in the developer UI, contradicting the README
("open the traces tab").

Register AgentexTracingProcessorConfig() ahead of the SGP block in all 16
framework templates (sync/default/temporal x openai-agents, pydantic-ai,
langgraph, claude-code, codex, plus the local-sandbox variant), fix a
sync-langgraph comment that claimed to register the Agentex processor, and
add a parametrized test asserting every framework template registers it.

Verified on a scaffolded sync Claude Code agent and a Temporal Claude Code
agent against a local backend: with the registration, message/turn spans
appear via POST /spans; without it, none do.

Claude-Session: https://claude.ai/code/session_01HCVKnA7LeJZ44nxZz1uzF3
…disabled

The runtime treats an explicitly empty AGENTEX_BASE_URL as "no backend" and
skips agent registration; registering the Agentex tracing processor
unconditionally would then make every span export fail. Guard the
registration on the same condition in all 16 framework templates.

Claude-Session: https://claude.ai/code/session_01HCVKnA7LeJZ44nxZz1uzF3
@michaelxu2288
michaelxu2288 force-pushed the fix/templates-local-tracing branch from 8a049a7 to ddb5d76 Compare October 1, 2026 09:40
@michaelxu2288
michaelxu2288 changed the base branch from next to main October 1, 2026 09:40
@greptile-apps

greptile-apps Bot commented Oct 1, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Security Local spans go to production src/agentex/_client.py:74 ▶

    When a scaffolded agent runs without AGENTEX_BASE_URL, its template turns on local tracing. The tracing processor creates Agentex() without a URL, so this new default sends span requests to production instead of the local backend. The local traces tab stays empty, and span inputs and outputs go to the wrong endpoint. Make the tracing client's endpoint match the backend used by the agent.

    How this was verified: The template enables tracing when the URL is unset, and the processor sends span content through a client that now defaults to production.

@michaelxu2288

Copy link
Copy Markdown
Author

Thanks for flagging this. #517 and scaleapi/scale-agentex#430 were both closed without merging on 09-15, and AgentexTracingProcessorConfig is still on main, so the import concern doesn't apply right now. I've rebased this onto main now that next is retired, and the templates still skip the Agentex processor when AGENTEX_BASE_URL is set to an empty string.

If the Postgres spans API is still on its way out, I'm happy to close this or rework it against whatever replaces it. Just let me know which you'd prefer.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants