fix: handle OpenAI compat type correctly in TestConnection

Kujtim Hoxha created

Change summary

internal/agent/agent.go             | 10 ++++++++++
internal/agent/templates/summary.md |  6 +++++-
internal/config/config.go           |  2 +-
3 files changed, 16 insertions(+), 2 deletions(-)

Detailed changes

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

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.

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"