MCPcopy Create free account
hub / github.com/anomalyco/opencode / finish

Function finish

packages/llm/src/protocols/utils/lifecycle.ts:80–100  ·  view source on GitHub ↗
(
  state: State,
  events: LLMEvent[],
  input: {
    readonly reason: FinishReason
    readonly usage?: Usage
    readonly providerMetadata?: ProviderMetadata
  },
)

Source from the content-addressed store, hash-verified

78}
79
80export const finish = (
81 state: State,
82 events: LLMEvent[],
83 input: {
84 readonly reason: FinishReason
85 readonly usage?: Usage
86 readonly providerMetadata?: ProviderMetadata
87 },
88): State => {
89 const stepped = closeOpenBlocks(stepStart(state, events), events)
90 events.push(
91 LLMEvent.stepFinish({
92 index: 0,
93 reason: input.reason,
94 usage: input.usage,
95 providerMetadata: input.providerMetadata,
96 }),
97 LLMEvent.finish(input),
98 )
99 return { ...stepped, stepStarted: false }
100}
101
102export * as Lifecycle from "./lifecycle"

Callers

nothing calls this directly

Calls 3

closeOpenBlocksFunction · 0.85
stepStartFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected