You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(sdk): add agents.run() and AgentStream.threadId
SDK:
- AgentStream now extracts threadId and userMessageId from the
thread_info data event during streaming
- New agents.run(agentId, { message, threadId?, timeoutMs? }) method:
sends a task, waits for result, returns { response, threadId, status }
- Internally streams to collect text + threadId, falls back to polling
GET /agent-threads/{id}/messages if stream returns empty
- Export AgentRunResult, AgentRunOptions types
CLI:
- `af agent run` now delegates to sdk agents.run() (was 80 lines inline,
now 20 lines)
- Returns structured JSON: { schema, status, agent_id, thread_id, response }
Usage (AI agent calling via Bash):
af agent run --agent-id <id> --message "Analyze X" --json
→ {"status":"completed","thread_id":"...","response":"..."}
fail("agent_run_failed",`Agent run failed (thread: ${resolvedThreadId})`);
3704
-
}
3705
-
}catch{/* thread not ready yet */}
3706
-
awaitnewPromise((r)=>setTimeout(r,pollMs));
3642
+
if(result.status==="timeout"){
3643
+
fail("agent_run_timeout",
3644
+
`Agent did not respond within ${opts.timeout}s`,
3645
+
`Thread: ${result.threadId}. Check with: af agent-threads messages --thread-id ${result.threadId}`);
3707
3646
}
3708
3647
3709
-
fail("agent_run_timeout",`Agent did not respond within ${opts.timeout}s`,`Thread: ${resolvedThreadId}. Check with: af agent-threads messages --thread-id ${resolvedThreadId}`);
0 commit comments