fix: address code review findings
- Export TraceEventBase for consumer utility functions - Make agent required on TraceEventBase (all subtypes already require it) - Make model required on LLMCallTrace (always populated from RunnerOptions) - Fix retryCount to use increment instead of attempt assignment - Add TODO comments for prompt()/stream() trace forwarding
This commit is contained in:
parent
f4d3bb4e8d
commit
a49b24c22a
|
|
@ -175,6 +175,7 @@ export class Agent {
|
||||||
*
|
*
|
||||||
* Use this for multi-turn interactions.
|
* Use this for multi-turn interactions.
|
||||||
*/
|
*/
|
||||||
|
// TODO(#18): accept optional RunOptions to forward trace context
|
||||||
async prompt(message: string): Promise<AgentRunResult> {
|
async prompt(message: string): Promise<AgentRunResult> {
|
||||||
const userMessage: LLMMessage = {
|
const userMessage: LLMMessage = {
|
||||||
role: 'user',
|
role: 'user',
|
||||||
|
|
@ -198,6 +199,7 @@ export class Agent {
|
||||||
*
|
*
|
||||||
* Like {@link run}, this does not use or update the persistent history.
|
* Like {@link run}, this does not use or update the persistent history.
|
||||||
*/
|
*/
|
||||||
|
// TODO(#18): accept optional RunOptions to forward trace context
|
||||||
async *stream(prompt: string): AsyncGenerator<StreamEvent> {
|
async *stream(prompt: string): AsyncGenerator<StreamEvent> {
|
||||||
const messages: LLMMessage[] = [
|
const messages: LLMMessage[] = [
|
||||||
{ role: 'user', content: [{ type: 'text', text: prompt }] },
|
{ role: 'user', content: [{ type: 'text', text: prompt }] },
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ export type {
|
||||||
OrchestratorEvent,
|
OrchestratorEvent,
|
||||||
|
|
||||||
// Trace
|
// Trace
|
||||||
|
TraceEventBase,
|
||||||
TraceEvent,
|
TraceEvent,
|
||||||
LLMCallTrace,
|
LLMCallTrace,
|
||||||
ToolCallTrace,
|
ToolCallTrace,
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ async function executeQueue(
|
||||||
() => pool.run(assignee, prompt, traceOptions),
|
() => pool.run(assignee, prompt, traceOptions),
|
||||||
task,
|
task,
|
||||||
(retryData) => {
|
(retryData) => {
|
||||||
retryCount = retryData.attempt
|
retryCount++
|
||||||
config.onProgress?.({
|
config.onProgress?.({
|
||||||
type: 'task_retry',
|
type: 'task_retry',
|
||||||
task: task.id,
|
task: task.id,
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ export interface OrchestratorConfig {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
/** Shared fields present on every trace event. */
|
/** Shared fields present on every trace event. */
|
||||||
interface TraceEventBase {
|
export interface TraceEventBase {
|
||||||
/** Unique identifier for the entire run (runTeam / runTasks / runAgent call). */
|
/** Unique identifier for the entire run (runTeam / runTasks / runAgent call). */
|
||||||
readonly runId: string
|
readonly runId: string
|
||||||
readonly type: string
|
readonly type: string
|
||||||
|
|
@ -335,7 +335,7 @@ interface TraceEventBase {
|
||||||
/** Wall-clock duration in milliseconds (`endMs - startMs`). */
|
/** Wall-clock duration in milliseconds (`endMs - startMs`). */
|
||||||
readonly durationMs: number
|
readonly durationMs: number
|
||||||
/** Agent name associated with this span. */
|
/** Agent name associated with this span. */
|
||||||
readonly agent?: string
|
readonly agent: string
|
||||||
/** Task ID associated with this span. */
|
/** Task ID associated with this span. */
|
||||||
readonly taskId?: string
|
readonly taskId?: string
|
||||||
}
|
}
|
||||||
|
|
@ -344,7 +344,7 @@ interface TraceEventBase {
|
||||||
export interface LLMCallTrace extends TraceEventBase {
|
export interface LLMCallTrace extends TraceEventBase {
|
||||||
readonly type: 'llm_call'
|
readonly type: 'llm_call'
|
||||||
readonly agent: string
|
readonly agent: string
|
||||||
readonly model?: string
|
readonly model: string
|
||||||
readonly turn: number
|
readonly turn: number
|
||||||
readonly tokens: TokenUsage
|
readonly tokens: TokenUsage
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue