Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/backends/opencode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export interface OpencodeBackendOptions {
export class OpencodeBackend implements Backend {
readonly name = 'opencode'
readonly defaultExecutionTimeoutMs: number
// The signal plugin reports a call at its start; it is installed in the turn's private config
// directory, which every turn with an AgentProfile has (agent-runtime always sends one).
readonly toolCallSpans = true
private readonly spawner: Spawner
constructor(private readonly opts: OpencodeBackendOptions) {
this.defaultExecutionTimeoutMs = opts.timeoutMs
Expand Down
6 changes: 6 additions & 0 deletions src/backends/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,12 @@ export interface Backend {
readonly name: string
/** Operator-selected fallback used only when `execution.timeoutMs` is absent. Zero/absent means no deadline. */
readonly defaultExecutionTimeoutMs?: number
/**
* The stream reports each tool call when it starts and its outcome when it ends, so a caller can
* tell a silent model from a running tool. Served as `toolCallSpans` on `/v1/capabilities`;
* agent-runtime runs `modelSilenceMs` only on a route that declares it.
*/
readonly toolCallSpans?: boolean

/** Does this backend want to handle requests for `model`? */
matches(model: string): boolean
Expand Down
9 changes: 6 additions & 3 deletions src/sessions/retained.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ export class RetainedSessionService {
return parseNativeContinuation(value)
}

async capabilities(model: string, signal?: AbortSignal): Promise<AgentEnvironmentCapabilities> {
const { capabilities } = await readyBackendCapabilities({
async capabilities(
model: string,
signal?: AbortSignal,
): Promise<AgentEnvironmentCapabilities & { toolCallSpans?: true }> {
const { backend, capabilities } = await readyBackendCapabilities({
registry: this.registry,
model,
healthProbeTimeoutMs: this.healthProbeTimeoutMs,
signal,
})
return capabilities
return backend.toolCallSpans ? { ...capabilities, toolCallSpans: true } : capabilities
}

async create(input: RetainedCreateInput, signal?: AbortSignal): Promise<RetainedSessionView> {
Expand Down
8 changes: 8 additions & 0 deletions tests/retained-sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,14 @@ describe('retained Agent Interface sessions', () => {
})
expect(capabilities).not.toHaveProperty('nativeContinuation')
expect(capabilities).not.toHaveProperty('interactions')
expect(capabilities).not.toHaveProperty('toolCallSpans')
})

it('declares toolCallSpans only for a backend whose stream reports a call at its start and end', async () => {
fixture = setup(Object.assign(new OneShotBackend('opencode'), { toolCallSpans: true }))
const response = await fixture.app.request('/v1/capabilities?model=opencode%2Ftest')
expect(response.status).toBe(200)
expect(await json(response)).toMatchObject({ toolCallSpans: true, streaming: { live: true } })
})

it('refuses retained capability discovery and creation until native health is ready', async () => {
Expand Down