Skip to content

Commit ddb5d76

Browse files
committed
fix(templates): skip the local tracing processor when the backend is 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
1 parent b761ee3 commit ddb5d76

16 files changed

Lines changed: 80 additions & 32 deletions

File tree

‎src/agentex/lib/cli/templates/default-claude-code/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ from agentex.lib.core.tracing.tracing_processor_manager import add_tracing_proce
3333

3434
logger = make_logger(__name__)
3535

36-
# Local Agentex backend: spans appear in the developer UI's traces tab.
37-
add_tracing_processor_config(AgentexTracingProcessorConfig())
36+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
37+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
38+
# as disabled and skips agent registration too).
39+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
40+
add_tracing_processor_config(AgentexTracingProcessorConfig())
3841

3942
add_tracing_processor_config(
4043
SGPTracingProcessorConfig(

‎src/agentex/lib/cli/templates/default-codex/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ from agentex.lib.core.tracing.tracing_processor_manager import add_tracing_proce
4343

4444
logger = make_logger(__name__)
4545

46-
# Local Agentex backend: spans appear in the developer UI's traces tab.
47-
add_tracing_processor_config(AgentexTracingProcessorConfig())
46+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
47+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
48+
# as disabled and skips agent registration too).
49+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
50+
add_tracing_processor_config(AgentexTracingProcessorConfig())
4851

4952
add_tracing_processor_config(
5053
SGPTracingProcessorConfig(

‎src/agentex/lib/cli/templates/default-langgraph/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ from project.graph import create_graph
2929

3030
logger = make_logger(__name__)
3131

32-
# Local Agentex backend: spans appear in the developer UI's traces tab.
33-
add_tracing_processor_config(AgentexTracingProcessorConfig())
32+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
33+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
34+
# as disabled and skips agent registration too).
35+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
36+
add_tracing_processor_config(AgentexTracingProcessorConfig())
3437

3538
add_tracing_processor_config(
3639
SGPTracingProcessorConfig(

‎src/agentex/lib/cli/templates/default-openai-agents/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ if _litellm_key and not os.environ.get("OPENAI_API_KEY"):
5555

5656
_sgp_api_key = os.environ.get("SGP_API_KEY", "")
5757
_sgp_account_id = os.environ.get("SGP_ACCOUNT_ID", "")
58-
# Local Agentex backend: spans appear in the developer UI's traces tab.
59-
add_tracing_processor_config(AgentexTracingProcessorConfig())
58+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
59+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
60+
# as disabled and skips agent registration too).
61+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
62+
add_tracing_processor_config(AgentexTracingProcessorConfig())
6063

6164
if _sgp_api_key and _sgp_account_id:
6265
add_tracing_processor_config(

‎src/agentex/lib/cli/templates/default-pydantic-ai/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ logger = make_logger(__name__)
4242
# so they show up in the per-task spans dropdown out of the box.
4343
SGP_API_KEY = os.environ.get("SGP_API_KEY", "")
4444
SGP_ACCOUNT_ID = os.environ.get("SGP_ACCOUNT_ID", "")
45-
# Local Agentex backend: spans appear in the developer UI's traces tab.
46-
add_tracing_processor_config(AgentexTracingProcessorConfig())
45+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
46+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
47+
# as disabled and skips agent registration too).
48+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
49+
add_tracing_processor_config(AgentexTracingProcessorConfig())
4750

4851
if SGP_API_KEY and SGP_ACCOUNT_ID:
4952
add_tracing_processor_config(

‎src/agentex/lib/cli/templates/sync-claude-code/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ from agentex.lib.core.tracing.tracing_processor_manager import add_tracing_proce
3535

3636
logger = make_logger(__name__)
3737

38-
# Local Agentex backend: spans appear in the developer UI's traces tab.
39-
add_tracing_processor_config(AgentexTracingProcessorConfig())
38+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
39+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
40+
# as disabled and skips agent registration too).
41+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
42+
add_tracing_processor_config(AgentexTracingProcessorConfig())
4043

4144
add_tracing_processor_config(
4245
SGPTracingProcessorConfig(

‎src/agentex/lib/cli/templates/sync-codex/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ from agentex.lib.core.tracing.tracing_processor_manager import add_tracing_proce
4444

4545
logger = make_logger(__name__)
4646

47-
# Local Agentex backend: spans appear in the developer UI's traces tab.
48-
add_tracing_processor_config(AgentexTracingProcessorConfig())
47+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
48+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
49+
# as disabled and skips agent registration too).
50+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
51+
add_tracing_processor_config(AgentexTracingProcessorConfig())
4952

5053
add_tracing_processor_config(
5154
SGPTracingProcessorConfig(

‎src/agentex/lib/cli/templates/sync-langgraph/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ from project.graph import create_graph
3333

3434
logger = make_logger(__name__)
3535

36-
# Local Agentex backend: spans appear in the developer UI's traces tab.
37-
add_tracing_processor_config(AgentexTracingProcessorConfig())
36+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
37+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
38+
# as disabled and skips agent registration too).
39+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
40+
add_tracing_processor_config(AgentexTracingProcessorConfig())
3841

3942
# Register the Scale GenAI Platform (SGP) tracing processor
4043
add_tracing_processor_config(

‎src/agentex/lib/cli/templates/sync-openai-agents-local-sandbox/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ SGP_API_KEY = os.environ.get("SGP_API_KEY", "")
4242
SGP_ACCOUNT_ID = os.environ.get("SGP_ACCOUNT_ID", "")
4343
SGP_CLIENT_BASE_URL = os.environ.get("SGP_CLIENT_BASE_URL", "")
4444

45-
# Local Agentex backend: spans appear in the developer UI's traces tab.
46-
add_tracing_processor_config(AgentexTracingProcessorConfig())
45+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
46+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
47+
# as disabled and skips agent registration too).
48+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
49+
add_tracing_processor_config(AgentexTracingProcessorConfig())
4750

4851
if SGP_API_KEY and SGP_ACCOUNT_ID:
4952
add_tracing_processor_config(

‎src/agentex/lib/cli/templates/sync-openai-agents/project/acp.py.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ SGP_API_KEY = os.environ.get("SGP_API_KEY", "")
3939
SGP_ACCOUNT_ID = os.environ.get("SGP_ACCOUNT_ID", "")
4040
SGP_CLIENT_BASE_URL = os.environ.get("SGP_CLIENT_BASE_URL", "")
4141

42-
# Local Agentex backend: spans appear in the developer UI's traces tab.
43-
add_tracing_processor_config(AgentexTracingProcessorConfig())
42+
# Local Agentex backend: spans appear in the developer UI's traces tab. Skipped
43+
# when AGENTEX_BASE_URL is explicitly empty (the runtime then treats the backend
44+
# as disabled and skips agent registration too).
45+
if os.environ.get("AGENTEX_BASE_URL", "http://localhost:5003"):
46+
add_tracing_processor_config(AgentexTracingProcessorConfig())
4447

4548
if SGP_API_KEY and SGP_ACCOUNT_ID:
4649
add_tracing_processor_config(

0 commit comments

Comments
 (0)