Summary
The paid chat endpoint (/api/paid/{agent}/chat) calls task_service.execute_task() without specifying a timeout_seconds parameter, so it defaults to 120 seconds. Complex agent queries (e.g., real estate underwriting with market analysis) regularly exceed this, causing task timeouts. The payment verification succeeds but the execution fails, resulting in verify-only payment logs with no settlement — the caller sees a 500 error.
Component
Backend / Paid Chat Router
Priority
P2
Error
[TaskExecService] Failed to execute task on [agent]: Task execution timed out after 120 seconds
Payment log shows repeated verify (OK) followed by no settle, because the execution times out before producing a response.
Location
- File:
src/backend/routers/paid.py
- Line: ~167
- Function:
paid_chat()
Root Cause
The execute_task() call in the paid router doesn't pass timeout_seconds, defaulting to 120s:
exec_result = await task_service.execute_task(
agent_name=agent_name,
message=request_body.message,
triggered_by="paid",
resume_session_id=request_body.session_id,
)
The regular chat endpoint (/api/agents/{name}/chat) works fine because it uses the async background task pattern (no synchronous timeout). But the paid endpoint must wait synchronously for the result to settle the payment.
Reproduction Steps
- Configure Nevermined payments on an agent
- Send a complex query via the paid endpoint that takes >120s to process
- Payment verifies successfully
- Task execution times out at 120 seconds
- No settlement occurs — caller gets 500 error
- Payment log shows
verify (OK) but no corresponding settle
Suggested Fix
Add an explicit timeout_seconds parameter to the execute_task() call. 600 seconds (10 minutes) is a reasonable default for paid queries that involve tool use and research:
exec_result = await task_service.execute_task(
agent_name=agent_name,
message=request_body.message,
triggered_by="paid",
timeout_seconds=600,
resume_session_id=request_body.session_id,
)
Optionally, make this configurable per-agent via nevermined_agent_config.timeout_seconds.
Environment
- Trinity version:
f1dfd7d
- Component:
routers/paid.py, services/task_execution_service.py
Related
src/backend/services/task_execution_service.py — defines timeout_seconds=120 default
src/backend/routers/paid.py — paid chat endpoint
src/backend/services/nevermined_payment_service.py — payment flow
Summary
The paid chat endpoint (
/api/paid/{agent}/chat) callstask_service.execute_task()without specifying atimeout_secondsparameter, so it defaults to 120 seconds. Complex agent queries (e.g., real estate underwriting with market analysis) regularly exceed this, causing task timeouts. The payment verification succeeds but the execution fails, resulting in verify-only payment logs with no settlement — the caller sees a 500 error.Component
Backend / Paid Chat Router
Priority
P2
Error
Payment log shows repeated
verify(OK) followed by nosettle, because the execution times out before producing a response.Location
src/backend/routers/paid.pypaid_chat()Root Cause
The
execute_task()call in the paid router doesn't passtimeout_seconds, defaulting to 120s:The regular chat endpoint (
/api/agents/{name}/chat) works fine because it uses the async background task pattern (no synchronous timeout). But the paid endpoint must wait synchronously for the result to settle the payment.Reproduction Steps
verify(OK) but no correspondingsettleSuggested Fix
Add an explicit
timeout_secondsparameter to theexecute_task()call. 600 seconds (10 minutes) is a reasonable default for paid queries that involve tool use and research:Optionally, make this configurable per-agent via
nevermined_agent_config.timeout_seconds.Environment
f1dfd7drouters/paid.py,services/task_execution_service.pyRelated
src/backend/services/task_execution_service.py— definestimeout_seconds=120defaultsrc/backend/routers/paid.py— paid chat endpointsrc/backend/services/nevermined_payment_service.py— payment flow