fix(orchestrator): don't propagate non-billing charge errors as tool failures

Non-IBE exceptions from charge_node_usage (e.g. DB timeout) were
re-raised and caught by the outer generic handler, incorrectly marking
a successful tool execution as failed. This could cause the LLM to
retry side-effectful operations. Now logs the error and continues to
the success path since the tool itself completed successfully.
This commit is contained in:
majdyz
2026-04-13 07:02:10 +00:00
parent 5ff46ff207
commit e558c60104

View File

@@ -1192,13 +1192,16 @@ class OrchestratorBlock(Block):
raise
except Exception:
# Non-billing charge failures (DB outage, network, etc.)
# are logged with full traceback but surfaced to the LLM
# as a generic error to avoid leaking infrastructure details.
# must NOT propagate to the outer except handler because
# the tool itself succeeded. Re-raising would mark the
# tool as failed (_is_error=True), causing the LLM to
# retry side-effectful operations. Log and continue.
logger.exception(
"Unexpected error charging for tool node %s",
"Unexpected error charging for tool node %s; "
"tool execution was successful",
sink_node_id,
)
raise
tool_cost = 0
if tool_cost > 0:
self.merge_stats(NodeExecutionStats(extra_cost=tool_cost))