From 7d14abb965dcdf461ab0ca47981c49ce6ddd5055 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Mon, 20 Oct 2025 12:02:03 +0200 Subject: [PATCH] fix: handle OpenAI compat type correctly in TestConnection --- internal/agent/agent.go | 10 ++++++++++ internal/agent/templates/summary.md | 6 +++++- internal/config/config.go | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 648c8969ea7e15ca99c9f50e882138574e5d17e7..cb0b71a99155362f792a703fd5fea4d89e5c7c8f 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -430,6 +430,16 @@ func (a *sessionAgent) Run(ctx context.Context, call SessionAgentCall) (*fantasy if summarizeErr := a.Summarize(genCtx, call.SessionID, call.ProviderOptions); summarizeErr != nil { return nil, summarizeErr } + // if the agent was not done... + if len(currentAssistant.ToolCalls()) > 0 { + existing, ok := a.messageQueue.Get(call.SessionID) + if !ok { + existing = []SessionAgentCall{} + } + call.Prompt = fmt.Sprintf("The previous session was interrupted because it got too long, the initial user request was: `%s`", call.Prompt) + existing = append(existing, call) + a.messageQueue.Set(call.SessionID, existing) + } } // release active request before processing queued messages diff --git a/internal/agent/templates/summary.md b/internal/agent/templates/summary.md index 94d2134df0bdc0a61e417ffe26913293ab6e1db1..600de27caff1238f4cef5896e8312eb7e0bc7212 100644 --- a/internal/agent/templates/summary.md +++ b/internal/agent/templates/summary.md @@ -10,4 +10,8 @@ Focus on information that would be helpful for continuing the conversation, incl - Any context that would be needed to continue working on the task - What needs to be done next -Your summary should be comprehensive enough to provide context but concise enough to be quickly understood. +Your summary should be comprehensive enough to provide context to be quickly understood. + +It is very important to keep context of files that are important and strategy you are following. + +It is very important to have the next steps clearly defined. diff --git a/internal/config/config.go b/internal/config/config.go index 3cb7cdf9c5dc0a2aaeab7a9413ecd029be1ac8cc..a16be888f6a490bd122c1ed1b8f3934f099345f3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -542,7 +542,7 @@ func (c *ProviderConfig) TestConnection(resolver VariableResolver) error { headers := make(map[string]string) apiKey, _ := resolver.ResolveValue(c.APIKey) switch c.Type { - case catwalk.TypeOpenAI: + case catwalk.TypeOpenAI, catwalk.TypeOpenAICompat: baseURL, _ := resolver.ResolveValue(c.BaseURL) if baseURL == "" { baseURL = "https://api.openai.com/v1"