diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 7144efe0c93..c0e49b2a8cb 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -21311,6 +21311,10 @@ const docTemplate = `{ } } }, + "provider_credential": { + "description": "ProviderCredential records whether a reasoning part was produced\nwith the deployment's credential or the user's personal API key,\nbecause encrypted reasoning only decrypts for the organization\nbehind that credential. Internal only: stripped before API responses.", + "type": "string" + }, "provider_executed": { "description": "ProviderExecuted indicates the tool call was executed by\nthe provider (e.g. Anthropic computer use).", "type": "boolean" @@ -21333,6 +21337,10 @@ const docTemplate = `{ "reasoning_delta": { "type": "string" }, + "reasoning_epoch": { + "description": "ReasoningEpoch records how many times the producing provider had\nrejected the chat's encrypted reasoning before this reasoning part\nwas produced. Internal only: stripped before API responses.", + "type": "integer" + }, "result": { "type": "array", "items": { diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 4e5d747ec19..c87d4849f88 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -19241,6 +19241,10 @@ } } }, + "provider_credential": { + "description": "ProviderCredential records whether a reasoning part was produced\nwith the deployment's credential or the user's personal API key,\nbecause encrypted reasoning only decrypts for the organization\nbehind that credential. Internal only: stripped before API responses.", + "type": "string" + }, "provider_executed": { "description": "ProviderExecuted indicates the tool call was executed by\nthe provider (e.g. Anthropic computer use).", "type": "boolean" @@ -19263,6 +19267,10 @@ "reasoning_delta": { "type": "string" }, + "reasoning_epoch": { + "description": "ReasoningEpoch records how many times the producing provider had\nrejected the chat's encrypted reasoning before this reasoning part\nwas produced. Internal only: stripped before API responses.", + "type": "integer" + }, "result": { "type": "array", "items": { diff --git a/coderd/x/chatd/chatd.go b/coderd/x/chatd/chatd.go index c8c4e773789..66788512f1d 100644 --- a/coderd/x/chatd/chatd.go +++ b/coderd/x/chatd/chatd.go @@ -211,11 +211,6 @@ type Server struct { // model that accepted Anthropic's thinking drop_block control. thinkingDropBlock sync.Map - // rejectedReasoning holds the rejectedReasoningKey of each OpenAI - // reasoning item whose encrypted content a provider rejected. It grows - // only on rejections, which follow a credential change. - rejectedReasoning sync.Map - // Configuration inFlightChatStaleAfter time.Duration streamSilenceTimeout time.Duration diff --git a/coderd/x/chatd/chatprompt/chatprompt.go b/coderd/x/chatd/chatprompt/chatprompt.go index 6fbcc4d97a7..74316f64bf5 100644 --- a/coderd/x/chatd/chatprompt/chatprompt.go +++ b/coderd/x/chatd/chatprompt/chatprompt.go @@ -1903,6 +1903,7 @@ var partNulFields = []partNulField{ {name: "ParsedCommands", policy: nulReject, grid: func(p *codersdk.ChatMessagePart) [][]string { return p.ParsedCommands }}, {name: "ProviderIdentity", policy: nulReject, str: func(p *codersdk.ChatMessagePart) *string { return &p.ProviderIdentity }}, {name: "ProviderModel", policy: nulReject, str: func(p *codersdk.ChatMessagePart) *string { return &p.ProviderModel }}, + {name: "ProviderCredential", policy: nulReject, str: func(p *codersdk.ChatMessagePart) *string { return &p.ProviderCredential }}, {name: "SourceID", policy: nulReject, str: func(p *codersdk.ChatMessagePart) *string { return &p.SourceID }}, {name: "URL", policy: nulReject, str: func(p *codersdk.ChatMessagePart) *string { return &p.URL }}, {name: "MediaType", policy: nulReject, str: func(p *codersdk.ChatMessagePart) *string { return &p.MediaType }}, diff --git a/coderd/x/chatd/compaction_sanitize.go b/coderd/x/chatd/compaction_sanitize.go index 07467de4877..a246f7ccaab 100644 --- a/coderd/x/chatd/compaction_sanitize.go +++ b/coderd/x/chatd/compaction_sanitize.go @@ -5,7 +5,6 @@ import ( "fmt" "charm.land/fantasy" - fantasyopenai "charm.land/fantasy/providers/openai" "cdr.dev/slog/v3" "github.com/coder/coder/v2/coderd/database" @@ -136,30 +135,15 @@ func dropOpenAIReasoningParts( ctx context.Context, logger slog.Logger, messages []fantasy.Message, -) []fantasy.Message { - return dropOpenAIReasoningItems(ctx, logger, messages, func(string) bool { return true }) -} - -// dropOpenAIReasoningItems removes the OpenAI reasoning parts whose item ID -// satisfies drop from a copy of messages. Messages emptied by the drop are -// removed. -func dropOpenAIReasoningItems( - ctx context.Context, - logger slog.Logger, - messages []fantasy.Message, - drop func(itemID string) bool, ) []fantasy.Message { dropped := 0 out := make([]fantasy.Message, 0, len(messages)) for _, msg := range messages { parts := make([]fantasy.MessagePart, 0, len(msg.Content)) for _, part := range msg.Content { - if reasoning, ok := part.(fantasy.ReasoningPart); ok { - metadata := fantasyopenai.GetReasoningMetadata(reasoning.ProviderOptions) - if metadata != nil && metadata.ItemID != "" && drop(metadata.ItemID) { - dropped++ - continue - } + if reasoning, ok := part.(fantasy.ReasoningPart); ok && chatsanitize.HasOpenAIReasoningState(reasoning.ProviderOptions) { + dropped++ + continue } parts = append(parts, part) } diff --git a/coderd/x/chatd/encrypted_reasoning_fallback.go b/coderd/x/chatd/encrypted_reasoning_fallback.go index dff13a6e09e..48bbe9966f9 100644 --- a/coderd/x/chatd/encrypted_reasoning_fallback.go +++ b/coderd/x/chatd/encrypted_reasoning_fallback.go @@ -3,7 +3,7 @@ package chatd import ( "context" "errors" - "sync" + "sync/atomic" "charm.land/fantasy" "github.com/google/uuid" @@ -18,45 +18,35 @@ func isInvalidEncryptedContentError(err error) bool { return errors.As(err, &apiErr) && apiErr.Code == "invalid_encrypted_content" } -type rejectedReasoningKey struct { - chatID uuid.UUID - itemID string -} - // withEncryptedReasoningFallback wraps OpenAI Responses models in an -// encryptedReasoningFallbackModel. -func (p *Server) withEncryptedReasoningFallback(model chatprovider.Model, chatID uuid.UUID) chatprovider.Model { +// encryptedReasoningFallbackModel that sets rejected when it retries. +func (p *Server) withEncryptedReasoningFallback(model chatprovider.Model, chatID uuid.UUID, rejected *atomic.Bool) chatprovider.Model { if !model.Transport().UsesResponses() { return model } return model.WithLanguageModel(&encryptedReasoningFallbackModel{ LanguageModel: model.LanguageModel(), logger: p.logger.With(slog.F("chat_id", chatID)), - rejected: &p.rejectedReasoning, - chatID: chatID, + rejected: rejected, }) } // encryptedReasoningFallbackModel retries a request without OpenAI reasoning // when the provider rejects its encrypted content. Encrypted reasoning only // decrypts for the OpenAI organization that produced it, which can change -// without a provider or model change, for example when a user adds or -// removes a personal API key. The rejected reasoning stays in the chat -// history, so the model remembers its item IDs and leaves them out of later -// requests, while reasoning produced after the change still replays. +// without a provider, model, or credential change, for example when an admin +// replaces the deployment key with one from another organization. The +// rejected reasoning stays in the chat history, so the step stamps its new +// reasoning with the next epoch, and later steps leave out reasoning from +// earlier epochs. type encryptedReasoningFallbackModel struct { fantasy.LanguageModel logger slog.Logger - rejected *sync.Map - chatID uuid.UUID + rejected *atomic.Bool } // Stream retries only when the rejection arrives before any output. func (m *encryptedReasoningFallbackModel) Stream(ctx context.Context, call fantasy.Call) (fantasy.StreamResponse, error) { - call.Prompt = dropOpenAIReasoningItems(ctx, m.logger, call.Prompt, func(itemID string) bool { - _, rejected := m.rejected.Load(rejectedReasoningKey{chatID: m.chatID, itemID: itemID}) - return rejected - }) stream, err := m.LanguageModel.Stream(ctx, call) if err != nil { return nil, err @@ -77,19 +67,9 @@ func (m *encryptedReasoningFallbackModel) Stream(ctx context.Context, call fanta if rejection == nil { return } - // The error names a single item, but a credential change - // invalidates all earlier reasoning, so every remaining item - // counts as rejected. - remembered := 0 - call.Prompt = dropOpenAIReasoningItems(ctx, m.logger, call.Prompt, func(itemID string) bool { - m.rejected.Store(rejectedReasoningKey{chatID: m.chatID, itemID: itemID}, struct{}{}) - remembered++ - return true - }) - m.logger.Warn(ctx, "retrying model call without rejected encrypted reasoning", - slog.F("rejected_items", remembered), - slogError(rejection), - ) + m.rejected.Store(true) + m.logger.Warn(ctx, "retrying model call without rejected encrypted reasoning", slogError(rejection)) + call.Prompt = dropOpenAIReasoningParts(ctx, m.logger, call.Prompt) retry, err := m.LanguageModel.Stream(ctx, call) if err != nil { yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeError, Error: err}) diff --git a/coderd/x/chatd/generation.go b/coderd/x/chatd/generation.go index 6da6a9a2eca..715bd8b1ef8 100644 --- a/coderd/x/chatd/generation.go +++ b/coderd/x/chatd/generation.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "strings" + "sync/atomic" "time" "charm.land/fantasy" @@ -73,6 +74,9 @@ type generationPrepared struct { // user-facing errors. See chatloop.GenerateAssistantOptions.ErrorProvider. ResolvedProvider string ReasoningProvenance reasoningProvenance + // ReasoningRejected reports whether the provider rejected the + // encrypted reasoning replayed into this step's model call. + ReasoningRejected *atomic.Bool StageModel chatloop.StageModel @@ -94,6 +98,17 @@ type generationPrepared struct { Debug *generationDebug } +// stepReasoningProvenance returns the provenance to stamp on the step's +// reasoning. A rejection starts the provider's next epoch, so later steps +// leave out the reasoning the rejected call replayed. +func (p generationPrepared) stepReasoningProvenance() reasoningProvenance { + provenance := p.ReasoningProvenance + if p.ReasoningRejected != nil && p.ReasoningRejected.Load() { + provenance.Epoch++ + } + return provenance +} + // generationCompaction contains compaction inputs prepared for generation. type generationCompaction struct { // Override, when non-nil, is the compaction model override resolved at @@ -967,7 +982,7 @@ func (s *taskStarter) generateAssistant( logger: s.opts.Logger, contentVersion: chatprompt.CurrentContentVersion, hookRewrittenToolCalls: preflight.Overrides, - reasoningProvenance: prepared.ReasoningProvenance, + reasoningProvenance: prepared.stepReasoningProvenance(), }) if err != nil { return s.finishGenerationError(ctx, machine, input, err, requireGenerationAttempt(attempt.number)) @@ -1202,7 +1217,7 @@ func (s *taskStarter) executeLocalTools( toolNameToConfigID: prepared.ToolNameToConfigID, logger: s.opts.Logger, contentVersion: chatprompt.CurrentContentVersion, - reasoningProvenance: prepared.ReasoningProvenance, + reasoningProvenance: prepared.stepReasoningProvenance(), }) if err != nil { return s.finishGenerationError(ctx, machine, input, err, requireGenerationAttempt(attempt.number)) diff --git a/coderd/x/chatd/generation_preparer.go b/coderd/x/chatd/generation_preparer.go index dc361306966..3e93ba837af 100644 --- a/coderd/x/chatd/generation_preparer.go +++ b/coderd/x/chatd/generation_preparer.go @@ -175,7 +175,11 @@ func (server *Server) prepareGeneration( } model := resolved.model callConfig := resolved.callConfig - reasoningSource := reasoningProvenance{ProviderIdentity: providerIdentity, Model: model.ModelID()} + reasoningSource := reasoningProvenance{ + ProviderIdentity: providerIdentity, + Model: model.ModelID(), + Credential: reasoningCredential(resolved.route.ProviderAuth), + } modelRoute := resolved.route currentPlanMode := chat.PlanMode @@ -329,11 +333,12 @@ func (server *Server) prepareGeneration( ) // Drop provider-executed tool history produced by a different provider, - // and OpenAI reasoning state produced by a different provider or model, - // before building the prompt. A provider that shares another's wire - // format (e.g. Bedrock and Anthropic) can still reject the other's - // provider-specific blocks, so a mid-chat provider switch must not - // replay them. + // and OpenAI reasoning state produced by a different provider, model, + // or credential, or before the provider's latest rejection of the + // chat's encrypted reasoning, before building the prompt. A provider + // that shares another's wire format (e.g. Bedrock and Anthropic) can + // still reject the other's provider-specific blocks, so a mid-chat + // provider switch must not replay them. // // The pending-user segment (trailing user rows the assistant has not // answered yet) is handled separately from here through prompt @@ -346,6 +351,7 @@ func (server *Server) prepareGeneration( // sanitizing everything, since the tail is user-only and the // sanitizer only rewrites assistant rows. pendingRowsStart := pendingUserSegmentStart(promptRows) + reasoningSource.Epoch = currentReasoningEpoch(promptRows[:pendingRowsStart], providerIdentity) sanitizedHead, err := server.sanitizeForeignProviderStateRows(ctx, logger, promptRows[:pendingRowsStart], chat.OwnerID, reasoningSource) if err != nil { return generationPrepared{}, err @@ -907,6 +913,7 @@ func (server *Server) prepareGeneration( ModelBuildOptions: modelOpts, ResolvedProvider: resolved.resolvedProvider, ReasoningProvenance: reasoningSource, + ReasoningRejected: resolved.reasoningRejected, StageModel: resolved.stageModel(), ModelConfigID: modelConfig.ID, CallTemplate: resolved.newCall(), diff --git a/coderd/x/chatd/integration_responses_test.go b/coderd/x/chatd/integration_responses_test.go index 0076a65a56a..386e94e0d2a 100644 --- a/coderd/x/chatd/integration_responses_test.go +++ b/coderd/x/chatd/integration_responses_test.go @@ -376,9 +376,26 @@ func TestOpenAIResponsesRetriesWithoutRejectedEncryptedReasoning(t *testing.T) { model := insertChatModelConfigWithCallConfig(t, db, user.ID, "openai", "gpt-4o", codersdk.ChatModelCallConfig{}) factory := chattest.NewMockAIBridgeTransport(t, openAIURL) - server := newOpenAIResponsesTestServer(t, db, ps, func(cfg *chatd.Config) { - cfg.AIBridgeTransportFactory = chatAIGatewayTransportFactoryPointer(factory) - }) + newServer := func() *chatd.Server { + return newOpenAIResponsesTestServer(t, db, ps, func(cfg *chatd.Config) { + cfg.AIBridgeTransportFactory = chatAIGatewayTransportFactoryPointer(factory) + }) + } + server := newServer() + sendMessage := func(server *chatd.Server, chatID uuid.UUID, text string) { + t.Helper() + _, err := server.SendMessage(ctx, chatd.SendMessageOptions{ + ChatID: chatID, + CreatedBy: user.ID, + ModelConfigID: model.ID, + Content: []codersdk.ChatMessagePart{ + codersdk.ChatMessageText(text), + }, + }) + require.NoError(t, err) + waitForChatProcessed(ctx, t, db, chatID, server) + requireResponsesChatWaiting(ctx, t, db, chatID) + } chat, err := server.CreateChat(ctx, chatd.CreateOptions{ OrganizationID: org.ID, @@ -392,8 +409,94 @@ func TestOpenAIResponsesRetriesWithoutRejectedEncryptedReasoning(t *testing.T) { require.NoError(t, err) waitForChatProcessed(ctx, t, db, chat.ID, server) requireResponsesChatWaiting(ctx, t, db, chat.ID) + sendMessage(server, chat.ID, "list the templates") - for _, text := range []string{"list the templates", "thanks"} { + // The next turn runs on a server that never saw the rejection, like + // a restarted or different replica. + require.NoError(t, server.Close()) + sendMessage(newServer(), chat.ID, "thanks") + + // Only the first request after the change is rejected. + requests := recorder.all() + require.Len(t, requests, 5) + requireInlineReasoningItem(t, requests[1].Prompt, staleID, staleBlob, "") + retry := requests[2] + require.NotEmpty(t, retry.Prompt) + require.NotContains(t, promptItemTypes(retry.Prompt), "reasoning") + // requests[3] is the step after the tool call; requests[4] is the next + // turn on the fresh server. + for _, request := range requests[3:] { + requireInlineReasoningItem(t, request.Prompt, freshID, freshBlob, "") + requireNoResponsesProviderItemReplay(t, request.Prompt, staleID) + } +} + +func TestOpenAIResponsesReasoningNotReplayedAfterCredentialChange(t *testing.T) { + t.Parallel() + + db, ps := dbtestutil.NewDB(t) + ctx := testutil.Context(t, testutil.WaitLong) + + const ( + userAPIKey = "sk-user-reasoning" + deploymentID = "rs_deployment_key" + deploymentBlob = "encrypted-by-deployment-organization" + personalKeyID = "rs_personal_key" + personalKeyBlob = "encrypted-by-personal-organization" + ) + var ( + recorder responsesRequestRecorder + authMu sync.Mutex + authByCall = map[int]string{} + ) + openAIURL := chattest.NewOpenAI(t, func(req *chattest.OpenAIRequest) chattest.OpenAIResponse { + if !req.Stream { + return chattest.OpenAINonStreamingResponse("title") + } + n := recorder.record(req) + authMu.Lock() + authByCall[n] = req.Header.Get("Authorization") + authMu.Unlock() + resp := chattest.OpenAIStreamingResponse(chattest.OpenAITextChunks("answer")...) + switch n { + case 1: + resp.Reasoning = &chattest.OpenAIReasoningItem{ID: deploymentID, EncryptedContent: deploymentBlob} + case 2: + resp.Reasoning = &chattest.OpenAIReasoningItem{ID: personalKeyID, EncryptedContent: personalKeyBlob} + } + return resp + }) + + user, org, _ := seedChatDependenciesWithProvider(t, db, "openai", openAIURL) + model := insertChatModelConfigWithCallConfig(t, db, user.ID, "openai", "gpt-4o", + codersdk.ChatModelCallConfig{}) + factory := chattest.NewMockAIBridgeTransport(t, openAIURL) + server := newOpenAIResponsesTestServer(t, db, ps, func(cfg *chatd.Config) { + cfg.AIBridgeTransportFactory = chatAIGatewayTransportFactoryPointer(factory) + }) + + chat, err := server.CreateChat(ctx, chatd.CreateOptions{ + OrganizationID: org.ID, + OwnerID: user.ID, + Title: uniqueResponsesTitle(t, "credential-change"), + ModelConfigID: model.ID, + InitialUserContent: []codersdk.ChatMessagePart{ + codersdk.ChatMessageText("hello"), + }, + }) + require.NoError(t, err) + waitForChatProcessed(ctx, t, db, chat.ID, server) + requireResponsesChatWaiting(ctx, t, db, chat.ID) + + _, err = db.UpsertUserAIProviderKey(ctx, database.UpsertUserAIProviderKeyParams{ + ID: uuid.New(), + UserID: user.ID, + AIProviderID: model.AIProviderID.UUID, + APIKey: userAPIKey, + }) + require.NoError(t, err) + + for _, text := range []string{"switched keys", "thanks"} { _, err = server.SendMessage(ctx, chatd.SendMessageOptions{ ChatID: chat.ID, CreatedBy: user.ID, @@ -407,19 +510,18 @@ func TestOpenAIResponsesRetriesWithoutRejectedEncryptedReasoning(t *testing.T) { requireResponsesChatWaiting(ctx, t, db, chat.ID) } - // Only the first request after the change is rejected. requests := recorder.all() - require.Len(t, requests, 5) - requireInlineReasoningItem(t, requests[1].Prompt, staleID, staleBlob, "") - retry := requests[2] - require.NotEmpty(t, retry.Prompt) - require.NotContains(t, promptItemTypes(retry.Prompt), "reasoning") - // requests[3] continues the tool step from in-memory history; - // requests[4] rebuilds the prompt from persisted messages. - for _, request := range requests[3:] { - requireInlineReasoningItem(t, request.Prompt, freshID, freshBlob, "") - requireNoResponsesProviderItemReplay(t, request.Prompt, staleID) - } + require.Len(t, requests, 3) + authMu.Lock() + require.NotEqual(t, "Bearer "+userAPIKey, authByCall[1]) + require.Equal(t, "Bearer "+userAPIKey, authByCall[2]) + authMu.Unlock() + // Reasoning from the deployment's key is left out before the + // personal key's organization can reject it. + require.NotContains(t, promptItemTypes(requests[1].Prompt), "reasoning") + requireNoResponsesProviderItemReplay(t, requests[1].Prompt, deploymentID) + requireInlineReasoningItem(t, requests[2].Prompt, personalKeyID, personalKeyBlob, "") + requireNoResponsesProviderItemReplay(t, requests[2].Prompt, deploymentID) } func TestOpenAIResponsesAdvisorPromptOmitsReasoning(t *testing.T) { diff --git a/coderd/x/chatd/message_conversion.go b/coderd/x/chatd/message_conversion.go index 8df13a5950f..4f311274a34 100644 --- a/coderd/x/chatd/message_conversion.go +++ b/coderd/x/chatd/message_conversion.go @@ -55,6 +55,8 @@ func buildCommitStepMessages(input buildCommitStepMessagesInput) (stepMessagesFo if assistantParts[i].Type == codersdk.ChatMessagePartTypeReasoning { assistantParts[i].ProviderIdentity = input.reasoningProvenance.ProviderIdentity assistantParts[i].ProviderModel = input.reasoningProvenance.Model + assistantParts[i].ProviderCredential = input.reasoningProvenance.Credential + assistantParts[i].ReasoningEpoch = input.reasoningProvenance.Epoch } } diff --git a/coderd/x/chatd/message_conversion_test.go b/coderd/x/chatd/message_conversion_test.go index 7cee1fbfe9a..6145259d02d 100644 --- a/coderd/x/chatd/message_conversion_test.go +++ b/coderd/x/chatd/message_conversion_test.go @@ -30,10 +30,15 @@ func TestBuildCommitStepMessages_AssistantTextAndReasoning(t *testing.T) { startedAt := time.Date(2026, 1, 2, 3, 4, 5, 0, time.UTC) completedAt := startedAt.Add(2 * time.Second) got, err := buildCommitStepMessages(buildCommitStepMessagesInput{ - modelConfigID: modelConfigID, - contentVersion: chatprompt.CurrentContentVersion, - logger: slog.Make(), - reasoningProvenance: reasoningProvenance{ProviderIdentity: "provider-a", Model: "model-a"}, + modelConfigID: modelConfigID, + contentVersion: chatprompt.CurrentContentVersion, + logger: slog.Make(), + reasoningProvenance: reasoningProvenance{ + ProviderIdentity: "provider-a", + Model: "model-a", + Credential: reasoningCredentialUser, + Epoch: 2, + }, step: stepData{ Content: []fantasy.Content{ fantasy.ReasoningContent{Text: "thinking"}, @@ -59,10 +64,14 @@ func TestBuildCommitStepMessages_AssistantTextAndReasoning(t *testing.T) { require.Equal(t, completedAt, requireNotNilTime(t, parts[0].CompletedAt)) require.Equal(t, "provider-a", parts[0].ProviderIdentity) require.Equal(t, "model-a", parts[0].ProviderModel) + require.Equal(t, reasoningCredentialUser, parts[0].ProviderCredential) + require.Equal(t, 2, parts[0].ReasoningEpoch) require.Equal(t, codersdk.ChatMessagePartTypeText, parts[1].Type) require.Equal(t, "hello", parts[1].Text) require.Empty(t, parts[1].ProviderIdentity) require.Empty(t, parts[1].ProviderModel) + require.Empty(t, parts[1].ProviderCredential) + require.Zero(t, parts[1].ReasoningEpoch) } func TestBuildCommitStepMessages_LocalToolResultsBecomeToolMessages(t *testing.T) { diff --git a/coderd/x/chatd/modelcall.go b/coderd/x/chatd/modelcall.go index e44324cc435..f323b3422f6 100644 --- a/coderd/x/chatd/modelcall.go +++ b/coderd/x/chatd/modelcall.go @@ -2,6 +2,7 @@ package chatd import ( "context" + "sync/atomic" "charm.land/fantasy" "golang.org/x/xerrors" @@ -72,6 +73,9 @@ type resolvedModelCall struct { resolvedEffort string route aiGatewayModelRoute debugEnabled bool + // reasoningRejected reports whether the provider rejected encrypted + // reasoning replayed into a call to model. + reasoningRejected *atomic.Bool } // stageModel uses the configured provider type rather than @@ -182,7 +186,8 @@ func (p *Server) resolveModelCall(ctx context.Context, spec modelCallSpec) (reso return resolvedModelCall{}, xerrors.Errorf("create model: %w", err) } model = p.withThinkingDropBlock(model, out.route.Provider.ID, clientCallConfig, spec.chat.ID) - model = p.withEncryptedReasoningFallback(model, spec.chat.ID) + out.reasoningRejected = &atomic.Bool{} + model = p.withEncryptedReasoningFallback(model, spec.chat.ID, out.reasoningRejected) if out.debugEnabled { model = model.WithLanguageModel(chatdebug.WrapModel(model.LanguageModel(), debugSvc, chatdebug.RecorderOptions{ diff --git a/coderd/x/chatd/provider_switch_sanitize.go b/coderd/x/chatd/provider_switch_sanitize.go index 3f564abf1b9..59b9bd3f88b 100644 --- a/coderd/x/chatd/provider_switch_sanitize.go +++ b/coderd/x/chatd/provider_switch_sanitize.go @@ -38,13 +38,62 @@ func modelConfigProviderIdentity(modelConfig database.ChatModelConfig, normalize return normalizedProvider } -// reasoningProvenance identifies the provider instance and model that -// produced OpenAI reasoning state. Reasoning item IDs only resolve on the -// issuing provider instance, and encrypted content can be rejected by a -// different model. +const ( + reasoningCredentialDeployment = "deployment" + reasoningCredentialUser = "user" +) + +// reasoningProvenance identifies where OpenAI reasoning state was produced. +// Reasoning item IDs only resolve on the issuing provider instance, and +// encrypted content can be rejected by a different model or by the +// organization behind a different credential. Epoch counts the provider's +// rejections of the chat's encrypted reasoning, so reasoning replayed into +// a rejected call is never replayed again. type reasoningProvenance struct { ProviderIdentity string Model string + Credential string + Epoch int +} + +// reasoningCredential names the credential an AI Gateway route sends. +func reasoningCredential(auth aiGatewayProviderAuth) string { + if len(auth.Headers) > 0 { + return reasoningCredentialUser + } + return reasoningCredentialDeployment +} + +// unstampedReasoningProvenance is the provenance assumed for reasoning saved +// without a stamp: the row's model config, the target's credential, and the +// first epoch. +func unstampedReasoningProvenance(rowOrigin, target reasoningProvenance) reasoningProvenance { + return reasoningProvenance{ + ProviderIdentity: rowOrigin.ProviderIdentity, + Model: rowOrigin.Model, + Credential: target.Credential, + } +} + +// currentReasoningEpoch returns the highest epoch stamped on providerIdentity's +// reasoning in rows. +func currentReasoningEpoch(rows []database.ChatMessage, providerIdentity string) int { + epoch := 0 + for _, row := range rows { + if row.Role != database.ChatMessageRoleAssistant || !bytes.Contains(row.Content.RawMessage, []byte(`"reasoning_epoch"`)) { + continue + } + parts, err := chatprompt.ParseContent(row) + if err != nil { + continue + } + for _, part := range parts { + if part.Type == codersdk.ChatMessagePartTypeReasoning && part.ProviderIdentity == providerIdentity { + epoch = max(epoch, part.ReasoningEpoch) + } + } + } + return epoch } // stripForeignProviderStateRows drops provider-executed tool blocks (calls and @@ -76,7 +125,7 @@ func stripForeignProviderStateRows( origin := originOf(row.ModelConfigID) nativeRow := origin.ProviderIdentity == target.ProviderIdentity // Only stamped reasoning parts can be foreign when the row origin matches. - if origin == target && !bytes.Contains(row.Content.RawMessage, []byte(`"provider_identity"`)) { + if unstampedReasoningProvenance(origin, target) == target && !bytes.Contains(row.Content.RawMessage, []byte(`"provider_identity"`)) { out = append(out, row) continue } @@ -126,9 +175,14 @@ func stripForeignProviderStateRows( } func isForeignReasoning(part codersdk.ChatMessagePart, rowOrigin, target reasoningProvenance) bool { - source := rowOrigin + source := unstampedReasoningProvenance(rowOrigin, target) if part.ProviderIdentity != "" { - source = reasoningProvenance{ProviderIdentity: part.ProviderIdentity, Model: part.ProviderModel} + source = reasoningProvenance{ + ProviderIdentity: part.ProviderIdentity, + Model: part.ProviderModel, + Credential: part.ProviderCredential, + Epoch: part.ReasoningEpoch, + } } return source != target && hasOpenAIReasoningState(part) } diff --git a/coderd/x/chatd/provider_switch_sanitize_internal_test.go b/coderd/x/chatd/provider_switch_sanitize_internal_test.go index 428ea1fc745..b013c7dcfce 100644 --- a/coderd/x/chatd/provider_switch_sanitize_internal_test.go +++ b/coderd/x/chatd/provider_switch_sanitize_internal_test.go @@ -332,6 +332,65 @@ func TestStripForeignProviderStateRows(t *testing.T) { require.Equal(t, rows, got) require.Zero(t, stats) }) + + stampedFull := func(source reasoningProvenance) codersdk.ChatMessagePart { + p := stampedReasoning(source) + p.ProviderCredential = source.Credential + p.ReasoningEpoch = source.Epoch + return p + } + + t.Run("stamped reasoning from another credential dropped", func(t *testing.T) { + t.Parallel() + deployment := openAIInstance + deployment.Credential = reasoningCredentialDeployment + user := openAIInstance + user.Credential = reasoningCredentialUser + rows := []database.ChatMessage{ + assistantRow(t, openAIInstanceCfg, stampedFull(deployment), text("deployment")), + assistantRow(t, openAIInstanceCfg, stampedFull(user), text("user")), + } + got, stats := stripForeignProviderStateRows(rows, user, resolver) + require.Len(t, got, 2) + require.Equal(t, []codersdk.ChatMessagePart{text("deployment")}, partsOf(t, got[0])) + require.Equal(t, rows[1], got[1]) + require.Equal(t, providerSwitchStripStats{RemovedReasoning: 1}, stats) + }) + + t.Run("reasoning from an earlier epoch dropped", func(t *testing.T) { + t.Parallel() + current := openAIInstance + current.Epoch = 1 + rows := []database.ChatMessage{ + assistantRow(t, openAIInstanceCfg, openAIReasoning, text("unstamped")), + assistantRow(t, openAIInstanceCfg, stampedFull(openAIInstance), text("rejected")), + assistantRow(t, openAIInstanceCfg, stampedFull(current), text("current")), + } + got, stats := stripForeignProviderStateRows(rows, current, resolver) + require.Len(t, got, 3) + require.Equal(t, []codersdk.ChatMessagePart{text("unstamped")}, partsOf(t, got[0])) + require.Equal(t, []codersdk.ChatMessagePart{text("rejected")}, partsOf(t, got[1])) + require.Equal(t, rows[2], got[2]) + require.Equal(t, providerSwitchStripStats{RemovedReasoning: 2}, stats) + }) + + t.Run("current epoch is per provider", func(t *testing.T) { + t.Parallel() + epoch := func(source reasoningProvenance, n int) reasoningProvenance { + source.Epoch = n + return source + } + otherModelAhead := epoch(openAIInstanceOtherModel, 3) + rows := []database.ChatMessage{ + userRow(t, "hi"), + assistantRow(t, openAIInstanceCfg, stampedFull(epoch(openAIInstance, 2)), openAIReasoning), + assistantRow(t, openAIInstanceOtherModelCfg, stampedFull(otherModelAhead), text("done")), + assistantRow(t, openAIInstanceCfg, stampedFull(epoch(otherOpenAIInstance, 5))), + } + require.Equal(t, 3, currentReasoningEpoch(rows, openAIInstance.ProviderIdentity)) + require.Equal(t, 5, currentReasoningEpoch(rows, otherOpenAIInstance.ProviderIdentity)) + require.Zero(t, currentReasoningEpoch(rows, vllm.ProviderIdentity)) + }) } func TestModelConfigProviderIdentity(t *testing.T) { diff --git a/codersdk/chats.go b/codersdk/chats.go index 4fb019dd038..ebe85cb9490 100644 --- a/codersdk/chats.go +++ b/codersdk/chats.go @@ -514,6 +514,15 @@ type ChatMessagePart struct { // because a model config's model can change after the message was // written. Internal only: stripped before API responses. ProviderModel string `json:"provider_model,omitempty" typescript:"-"` + // ProviderCredential records whether a reasoning part was produced + // with the deployment's credential or the user's personal API key, + // because encrypted reasoning only decrypts for the organization + // behind that credential. Internal only: stripped before API responses. + ProviderCredential string `json:"provider_credential,omitempty" typescript:"-"` + // ReasoningEpoch records how many times the producing provider had + // rejected the chat's encrypted reasoning before this reasoning part + // was produced. Internal only: stripped before API responses. + ReasoningEpoch int `json:"reasoning_epoch,omitempty" typescript:"-"` // ProviderExecuted indicates the tool call was executed by // the provider (e.g. Anthropic computer use). ProviderExecuted bool `json:"provider_executed,omitempty" variants:"tool-call?,tool-result?"` @@ -602,6 +611,8 @@ func (p *ChatMessagePart) StripInternal() { p.ProviderMetadata = nil p.ProviderIdentity = "" p.ProviderModel = "" + p.ProviderCredential = "" + p.ReasoningEpoch = 0 if p.FileID.Valid { p.Data = nil } diff --git a/codersdk/chats_test.go b/codersdk/chats_test.go index 9fdf4431bad..82a5e37e5da 100644 --- a/codersdk/chats_test.go +++ b/codersdk/chats_test.go @@ -199,18 +199,22 @@ func TestChatMessagePart_StripInternal(t *testing.T) { t.Run("StripsProviderMetadata", func(t *testing.T) { t.Parallel() part := codersdk.ChatMessagePart{ - Type: codersdk.ChatMessagePartTypeToolCall, - ToolCallID: "call-1", - ToolName: "some_tool", - Args: json.RawMessage(`{"key":"value"}`), - ProviderMetadata: json.RawMessage(`{"type":"ephemeral"}`), - ProviderIdentity: "provider-1", - ProviderModel: "model-1", + Type: codersdk.ChatMessagePartTypeToolCall, + ToolCallID: "call-1", + ToolName: "some_tool", + Args: json.RawMessage(`{"key":"value"}`), + ProviderMetadata: json.RawMessage(`{"type":"ephemeral"}`), + ProviderIdentity: "provider-1", + ProviderModel: "model-1", + ProviderCredential: "user", + ReasoningEpoch: 2, } part.StripInternal() assert.Nil(t, part.ProviderMetadata) assert.Empty(t, part.ProviderIdentity) assert.Empty(t, part.ProviderModel) + assert.Empty(t, part.ProviderCredential) + assert.Zero(t, part.ReasoningEpoch) // Public fields preserved. assert.Equal(t, codersdk.ChatMessagePartTypeToolCall, part.Type) assert.Equal(t, "call-1", part.ToolCallID) @@ -309,6 +313,8 @@ func TestChatMessagePartVariantTags(t *testing.T) { "provider_metadata": "internal only, stripped by db2sdk before API responses", "provider_identity": "internal only, stripped by db2sdk before API responses", "provider_model": "internal only, stripped by db2sdk before API responses", + "provider_credential": "internal only, stripped by db2sdk before API responses", + "reasoning_epoch": "internal only, stripped by db2sdk before API responses", "context_file_content": "internal only, stripped before API responses (typescript:\"-\")", "context_file_os": "internal only, used during prompt expansion (typescript:\"-\")", "context_file_directory": "internal only, used during prompt expansion (typescript:\"-\")", diff --git a/docs/reference/api/chats.md b/docs/reference/api/chats.md index fdae3f9948c..8a14c221d29 100644 --- a/docs/reference/api/chats.md +++ b/docs/reference/api/chats.md @@ -2903,6 +2903,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/messages \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -2910,6 +2911,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/messages \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -2986,6 +2988,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/messages \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -2993,6 +2996,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/messages \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -3143,6 +3147,7 @@ curl -X POST http://coder-server:8080/api/v2/chats/{chat}/messages \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -3150,6 +3155,7 @@ curl -X POST http://coder-server:8080/api/v2/chats/{chat}/messages \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -3225,6 +3231,7 @@ curl -X POST http://coder-server:8080/api/v2/chats/{chat}/messages \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -3232,6 +3239,7 @@ curl -X POST http://coder-server:8080/api/v2/chats/{chat}/messages \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -3308,6 +3316,7 @@ curl -X POST http://coder-server:8080/api/v2/chats/{chat}/messages \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -3315,6 +3324,7 @@ curl -X POST http://coder-server:8080/api/v2/chats/{chat}/messages \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -3450,6 +3460,7 @@ curl -X PATCH http://coder-server:8080/api/v2/chats/{chat}/messages/{message} \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -3457,6 +3468,7 @@ curl -X PATCH http://coder-server:8080/api/v2/chats/{chat}/messages/{message} \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -3532,6 +3544,7 @@ curl -X PATCH http://coder-server:8080/api/v2/chats/{chat}/messages/{message} \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -3539,6 +3552,7 @@ curl -X PATCH http://coder-server:8080/api/v2/chats/{chat}/messages/{message} \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -4125,6 +4139,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/stream \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -4132,6 +4147,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/stream \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -4206,6 +4222,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/stream \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -4213,6 +4230,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/stream \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -4274,6 +4292,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/stream \ "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -4281,6 +4300,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/stream \ ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -4378,11 +4398,13 @@ Status Code **200** | `»»» media_type` | string | false | | | | `»»» name` | string | false | | | | `»»» parsed_commands` | array | false | | Parsed commands holds parsed programs from an execute tool call's shell command, one entry per simple command in source order. Each entry is [program] or [program, arg] where arg is the first non-flag positional argument. Program names are normalized to their base name (e.g. /usr/bin/go becomes go). Only populated when ToolName is "execute" and the command parses successfully; nil otherwise. | +| `»»» provider_credential` | string | false | | Provider credential records whether a reasoning part was produced with the deployment's credential or the user's personal API key, because encrypted reasoning only decrypts for the organization behind that credential. Internal only: stripped before API responses. | | `»»» provider_executed` | boolean | false | | Provider executed indicates the tool call was executed by the provider (e.g. Anthropic computer use). | | `»»» provider_identity` | string | false | | Provider identity records the provider that produced a reasoning part, because a model config's provider can change after the message was written. Internal only: stripped before API responses. | | `»»» provider_metadata` | array | false | | Provider metadata holds provider-specific response metadata (e.g. Anthropic cache control hints) as raw JSON. Internal only: stripped by db2sdk before API responses. | | `»»» provider_model` | string | false | | Provider model records the model that produced a reasoning part, because a model config's model can change after the message was written. Internal only: stripped before API responses. | | `»»» reasoning_delta` | string | false | | | +| `»»» reasoning_epoch` | integer | false | | Reasoning epoch records how many times the producing provider had rejected the chat's encrypted reasoning before this reasoning part was produced. Internal only: stripped before API responses. | | `»»» result` | array | false | | | | `»»» result_delta` | string | false | | | | `»»» result_reset` | boolean | false | | | diff --git a/docs/reference/api/schemas.md b/docs/reference/api/schemas.md index 77f5711f984..756503f2795 100644 --- a/docs/reference/api/schemas.md +++ b/docs/reference/api/schemas.md @@ -3238,6 +3238,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -3245,6 +3246,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -3335,6 +3337,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -3342,6 +3345,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -3393,11 +3397,13 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in | `media_type` | string | false | | | | `name` | string | false | | | | `parsed_commands` | array of array | false | | Parsed commands holds parsed programs from an execute tool call's shell command, one entry per simple command in source order. Each entry is [program] or [program, arg] where arg is the first non-flag positional argument. Program names are normalized to their base name (e.g. /usr/bin/go becomes go). Only populated when ToolName is "execute" and the command parses successfully; nil otherwise. | +| `provider_credential` | string | false | | Provider credential records whether a reasoning part was produced with the deployment's credential or the user's personal API key, because encrypted reasoning only decrypts for the organization behind that credential. Internal only: stripped before API responses. | | `provider_executed` | boolean | false | | Provider executed indicates the tool call was executed by the provider (e.g. Anthropic computer use). | | `provider_identity` | string | false | | Provider identity records the provider that produced a reasoning part, because a model config's provider can change after the message was written. Internal only: stripped before API responses. | | `provider_metadata` | array of integer | false | | Provider metadata holds provider-specific response metadata (e.g. Anthropic cache control hints) as raw JSON. Internal only: stripped by db2sdk before API responses. | | `provider_model` | string | false | | Provider model records the model that produced a reasoning part, because a model config's model can change after the message was written. Internal only: stripped before API responses. | | `reasoning_delta` | string | false | | | +| `reasoning_epoch` | integer | false | | Reasoning epoch records how many times the producing provider had rejected the chat's encrypted reasoning before this reasoning part was produced. Internal only: stripped before API responses. | | `result` | array of integer | false | | | | `result_delta` | string | false | | | | `result_reset` | boolean | false | | | @@ -3513,6 +3519,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -3520,6 +3527,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -3596,6 +3604,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -3603,6 +3612,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -4979,6 +4989,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -4986,6 +4997,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -5144,6 +5156,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -5151,6 +5164,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -5225,6 +5239,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -5232,6 +5247,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -5293,6 +5309,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -5300,6 +5317,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -5410,6 +5428,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -5417,6 +5436,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -6270,6 +6290,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -6277,6 +6298,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -6352,6 +6374,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -6359,6 +6382,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -6435,6 +6459,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -6442,6 +6467,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -9362,6 +9388,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -9369,6 +9396,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ], @@ -9444,6 +9472,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o "string" ] ], + "provider_credential": "string", "provider_executed": true, "provider_identity": "string", "provider_metadata": [ @@ -9451,6 +9480,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o ], "provider_model": "string", "reasoning_delta": "string", + "reasoning_epoch": 0, "result": [ 0 ],