persistPendingDynamicStep persists a step that has pending dynamic tool calls awaiting external execution. Returns ErrInterrupted when persistence fails because the chat was interrupted.
( ctx context.Context, opts RunOptions, result *stepResult, stepStart time.Time, dynamicCalls []fantasy.ToolCallContent, )
| 1400 | // tool calls awaiting external execution. Returns ErrInterrupted when |
| 1401 | // persistence fails because the chat was interrupted. |
| 1402 | func persistPendingDynamicStep( |
| 1403 | ctx context.Context, |
| 1404 | opts RunOptions, |
| 1405 | result *stepResult, |
| 1406 | stepStart time.Time, |
| 1407 | dynamicCalls []fantasy.ToolCallContent, |
| 1408 | ) error { |
| 1409 | pending := make([]PendingToolCall, 0, len(dynamicCalls)) |
| 1410 | for _, dc := range dynamicCalls { |
| 1411 | pending = append(pending, PendingToolCall{ |
| 1412 | ToolCallID: dc.ToolCallID, |
| 1413 | ToolName: dc.ToolName, |
| 1414 | Args: dc.Input, |
| 1415 | }) |
| 1416 | } |
| 1417 | |
| 1418 | contextLimit := extractContextLimitWithFallback(result.providerMetadata, opts.ContextLimitFallback) |
| 1419 | |
| 1420 | if err := opts.PersistStep(ctx, PersistedStep{ |
| 1421 | Content: result.content, |
| 1422 | Usage: result.usage, |
| 1423 | ContextLimit: contextLimit, |
| 1424 | ProviderResponseID: chatopenai.ExtractResponseIDIfStored(opts.ProviderOptions, result.providerMetadata), |
| 1425 | Runtime: time.Since(stepStart), |
| 1426 | PendingDynamicToolCalls: pending, |
| 1427 | ReasoningStartedAt: result.reasoningStartedAt, |
| 1428 | ReasoningCompletedAt: result.reasoningCompletedAt, |
| 1429 | }); err != nil { |
| 1430 | if errors.Is(err, ErrInterrupted) { |
| 1431 | persistInterruptedStep(ctx, opts, result) |
| 1432 | return ErrInterrupted |
| 1433 | } |
| 1434 | return xerrors.Errorf("persist step: %w", err) |
| 1435 | } |
| 1436 | return nil |
| 1437 | } |
| 1438 | |
| 1439 | // applyExclusiveToolPolicy checks whether toolCalls violate the |
| 1440 | // exclusive-tool policy declared by exclusiveToolNames. When a |
no test coverage detected