Skip to content

Commit 5b5da7c

Browse files
author
SentienceDEV
committed
updated trace schema
1 parent b135ea8 commit 5b5da7c

2 files changed

Lines changed: 50 additions & 5 deletions

File tree

src/agent-runtime.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
*/
4040

4141
import { Page } from 'playwright';
42-
import { v4 as uuidv4 } from 'uuid';
4342
import { Snapshot } from './types';
4443
import { AssertContext, Predicate } from './verification';
4544
import { Tracer } from './tracing/tracer';
@@ -741,22 +740,22 @@ export class AgentRuntime {
741740
*
742741
* @param goal - Description of what this step aims to achieve
743742
* @param stepIndex - Optional explicit step index (otherwise auto-increments)
744-
* @returns Generated stepId
743+
* @returns Generated stepId in format 'step-N' where N is the step index
745744
*/
746745
beginStep(goal: string, stepIndex?: number): string {
747746
// Clear previous step state
748747
this.assertionsThisStep = [];
749748

750-
// Generate new stepId
751-
this.stepId = uuidv4();
752-
753749
// Update step index
754750
if (stepIndex !== undefined) {
755751
this.stepIndex = stepIndex;
756752
} else {
757753
this.stepIndex += 1;
758754
}
759755

756+
// Generate stepId in 'step-N' format for Studio compatibility
757+
this.stepId = `step-${this.stepIndex}`;
758+
760759
return this.stepId;
761760
}
762761

tests/agent-runtime-assertions.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,52 @@ function makeElement(
4040
} as Element;
4141
}
4242

43+
describe('AgentRuntime.beginStep() stepId format', () => {
44+
it('generates stepId in step-N format', () => {
45+
const sink = new MockSink();
46+
const tracer = new Tracer('test-run', sink);
47+
const page = new MockPage('https://example.com') as any;
48+
const browserLike = {
49+
snapshot: async () => ({
50+
status: 'success',
51+
url: 'https://example.com',
52+
elements: [],
53+
timestamp: 't1',
54+
}),
55+
};
56+
57+
const runtime = new AgentRuntime(browserLike as any, page as any, tracer);
58+
59+
const stepId1 = runtime.beginStep('Step 1');
60+
expect(stepId1).toBe('step-1');
61+
expect(runtime.stepIndex).toBe(1);
62+
63+
const stepId2 = runtime.beginStep('Step 2');
64+
expect(stepId2).toBe('step-2');
65+
expect(runtime.stepIndex).toBe(2);
66+
});
67+
68+
it('generates stepId matching explicit stepIndex', () => {
69+
const sink = new MockSink();
70+
const tracer = new Tracer('test-run', sink);
71+
const page = new MockPage('https://example.com') as any;
72+
const browserLike = {
73+
snapshot: async () => ({
74+
status: 'success',
75+
url: 'https://example.com',
76+
elements: [],
77+
timestamp: 't1',
78+
}),
79+
};
80+
81+
const runtime = new AgentRuntime(browserLike as any, page as any, tracer);
82+
83+
const stepId = runtime.beginStep('Custom step', 10);
84+
expect(stepId).toBe('step-10');
85+
expect(runtime.stepIndex).toBe(10);
86+
});
87+
});
88+
4389
describe('AgentRuntime.assert() with state predicates', () => {
4490
it('uses snapshot context for enabled/disabled/value assertions', () => {
4591
const sink = new MockSink();

0 commit comments

Comments
 (0)