MCPcopy Index your code
hub / github.com/coder/coder / cloneProviderOptions

Function cloneProviderOptions

coderd/x/chatd/chatadvisor/runtime.go:72–91  ·  view source on GitHub ↗

cloneProviderOptions returns a copy of opts with pointer entries for known, in-place mutated provider option types replaced by a shallow struct copy. chatloop mutates the OpenAI Responses entry (PreviousResponseID) on chain-mode exit, so sharing the pointer with the parent run would let an advisor c

(opts fantasy.ProviderOptions)

Source from the content-addressed store, hash-verified

70// package mutates them, but callers that need true deep-copy semantics must
71// handle those fields explicitly.
72func cloneProviderOptions(opts fantasy.ProviderOptions) fantasy.ProviderOptions {
73 if opts == nil {
74 return nil
75 }
76 cloned := make(fantasy.ProviderOptions, len(opts))
77 for key, value := range opts {
78 switch typed := value.(type) {
79 case *fantasyopenai.ResponsesProviderOptions:
80 if typed == nil {
81 cloned[key] = value
82 continue
83 }
84 copied := *typed
85 cloned[key] = &copied
86 default:
87 cloned[key] = value
88 }
89 }
90 return cloned
91}
92
93// resetProviderOptionsForNestedCall strips inherited state from opts that
94// does not apply to an ephemeral advisor call. PreviousResponseID is

Callers 2

RunAdvisorMethod · 0.85
NewRuntimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected