Skip to content

Commit 8a2b1c2

Browse files
author
hzq
committed
Test live caller ownership independently of approval expiry
1 parent 8cee117 commit 8a2b1c2

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎test/harness-bridge.test.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import type { ModelMessage } from '../src/core/contracts.js';
44
import { makeBundle, builtin } from '../src/lang/bundle.js';
55
import { createGateway } from '../src/gateway/server.js';
66
import { WorkerRuntime } from '../src/fabric/worker.js';
7-
import { agent, FixtureModel, setup, token, waitFor } from './helpers.js';
7+
import { agent, FixtureModel, setup as gatewayFixture, token, waitFor } from './helpers.js';
88

99
// 桥接(docs/harness.md):内核智能体 × Chat Completions。全部离线:Fastify inject,确定性模型替身。
1010

11+
// These are contracts for live calls. Only the explicit expiry case needs a short deadline.
12+
const setup: typeof gatewayFixture = (driver, extra, options) =>
13+
gatewayFixture(driver, { approvalTimeoutMs: 300_000, ...extra }, options);
1114
type Fixture = Awaited<ReturnType<typeof setup>>;
1215
const BRIDGE = { 'x-oaa-client-tools': 'bridge' };
1316
const EDIT = {
@@ -127,7 +130,6 @@ test('bridge: an oversized normalized result neither appends a partial batch nor
127130
],
128131
},
129132
),
130-
{ approvalTimeoutMs: 30_000 },
131133
);
132134
try {
133135
publish(s);
@@ -384,8 +386,11 @@ test('bridge: unknown or foreign call ids fall back to a new request and leave t
384386
try {
385387
publish(s);
386388
const first = await chat(s, { messages: [USER] });
389+
assert.equal(first.statusCode, 200);
387390
const runId = first.headers['x-run-id'] as string;
388391
const call = first.json().choices[0].message.tool_calls[0];
392+
const original = s.store.getApproval(call.id, 'owner');
393+
assert.equal(original.status, 'pending');
389394

390395
const unknown = await chat(s, {
391396
messages: [USER, assistantCalls([{ id: 'call_nope' }]), toolMessage('call_nope', 'x')],
@@ -425,7 +430,7 @@ test('bridge: unknown or foreign call ids fall back to a new request and leave t
425430
undefined,
426431
);
427432
assert.equal(s.store.run(runId).status, 'requires_action');
428-
assert.equal(s.store.getApproval(call.id, 'owner').status, 'pending');
433+
assert.deepEqual(s.store.getApproval(call.id, 'owner'), original);
429434
} finally {
430435
await s.cleanup();
431436
}

0 commit comments

Comments
 (0)