From b96f736bd20f7573bef2269c96c86ab3f1a4ad29 Mon Sep 17 00:00:00 2001 From: shern-point Date: Thu, 30 Apr 2026 00:45:01 +0800 Subject: [PATCH] feat: preserve full prompt text across current_input_file rewrites Keep token accounting tied to the original prompt even after the live prompt is replaced with a neutral placeholder and hidden context file. --- internal/httpapi/openai/history/current_input_file.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/httpapi/openai/history/current_input_file.go b/internal/httpapi/openai/history/current_input_file.go index 981a5ee..6d8723a 100644 --- a/internal/httpapi/openai/history/current_input_file.go +++ b/internal/httpapi/openai/history/current_input_file.go @@ -35,6 +35,10 @@ func (s Service) ApplyCurrentInputFile(ctx context.Context, a *auth.RequestAuth, if strings.TrimSpace(fileText) == "" { return stdReq, errors.New("current user input file produced empty transcript") } + originalPromptTokenText := strings.TrimSpace(stdReq.PromptTokenText) + if originalPromptTokenText == "" { + originalPromptTokenText = strings.TrimSpace(stdReq.FinalPrompt) + } result, err := s.DS.UploadFile(ctx, a, dsclient.UploadFileRequest{ Filename: currentInputFilename, @@ -61,6 +65,7 @@ func (s Service) ApplyCurrentInputFile(ctx context.Context, a *auth.RequestAuth, stdReq.CurrentInputFileApplied = true stdReq.RefFileIDs = prependUniqueRefFileID(stdReq.RefFileIDs, fileID) stdReq.FinalPrompt, stdReq.ToolNames = promptcompat.BuildOpenAIPrompt(messages, stdReq.ToolsRaw, "", stdReq.ToolChoice, stdReq.Thinking) + stdReq.PromptTokenText = originalPromptTokenText return stdReq, nil }