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.
|
||||
*/
|
||||
// TODO(#18): accept optional RunOptions to forward trace context
|
||||
async prompt(message: string): Promise<AgentRunResult> {
|
||||
const userMessage: LLMMessage = {
|
||||
role: 'user',
|
||||
|
|
@ -198,6 +199,7 @@ export class Agent {
|
|||
*
|
||||
* 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> {
|
||||
const messages: LLMMessage[] = [
|
||||
{ role: 'user', content: [{ type: 'text', text: prompt }] },
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ export type {
|
|||
OrchestratorEvent,
|
||||
|
||||
// Trace
|
||||
TraceEventBase,
|
||||
TraceEvent,
|
||||
LLMCallTrace,
|
||||
ToolCallTrace,
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ async function executeQueue(
|
|||
() => pool.run(assignee, prompt, traceOptions),
|
||||
task,
|
||||
(retryData) => {
|
||||
retryCount = retryData.attempt
|
||||
retryCount++
|
||||
config.onProgress?.({
|
||||
type: 'task_retry',
|
||||
task: task.id,
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ export interface OrchestratorConfig {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** Shared fields present on every trace event. */
|
||||
interface TraceEventBase {
|
||||
export interface TraceEventBase {
|
||||
/** Unique identifier for the entire run (runTeam / runTasks / runAgent call). */
|
||||
readonly runId: string
|
||||
readonly type: string
|
||||
|
|
@ -335,7 +335,7 @@ interface TraceEventBase {
|
|||
/** Wall-clock duration in milliseconds (`endMs - startMs`). */
|
||||
readonly durationMs: number
|
||||
/** Agent name associated with this span. */
|
||||
readonly agent?: string
|
||||
readonly agent: string
|
||||
/** Task ID associated with this span. */
|
||||
readonly taskId?: string
|
||||
}
|
||||
|
|
@ -344,7 +344,7 @@ interface TraceEventBase {
|
|||
export interface LLMCallTrace extends TraceEventBase {
|
||||
readonly type: 'llm_call'
|
||||
readonly agent: string
|
||||
readonly model?: string
|
||||
readonly model: string
|
||||
readonly turn: number
|
||||
readonly tokens: TokenUsage
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue