Skip to content

Commit 288b2d8

Browse files
authored
Merge pull request #716 from dgageot/misc-2
More misc improvements
2 parents 53baee4 + b30bde5 commit 288b2d8

19 files changed

Lines changed: 100 additions & 52 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ agents:
309309
- `OPENAI_API_KEY` - OpenAI authentication
310310
- `ANTHROPIC_API_KEY` - Anthropic authentication
311311
- `GOOGLE_API_KEY` - Google/Gemini authentication
312+
- `MISTRAL_API_KEY` - Mistral authentication
312313
- `TELEMETRY_ENABLED` - Control telemetry (set to false to disable)
313314
- `CAGENT_HIDE_TELEMETRY_BANNER` - Hide telemetry banner message
314-
- `CAGENT_HIDE_FEEDBACK_LINK` - Hide feedback link
315315

316316
## Debugging and Troubleshooting
317317

cmd/root/new.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ func (f *newFlags) runNewCommand(cmd *cobra.Command, args []string) error {
7878
case os.Getenv("GOOGLE_API_KEY") != "":
7979
modelProvider = "google"
8080
out.Printf("%s\n\n", "GOOGLE_API_KEY found, using Google")
81+
case os.Getenv("MISTRAL_API_KEY") != "":
82+
modelProvider = "mistral"
83+
out.Printf("%s\n\n", "MISTRAL_API_KEY found, using Mistral")
8184
default:
8285
modelProvider = "dmr"
8386
out.Printf("%s\n\n", "⚠️ No provider credentials found, defaulting to Docker Model Runner (DMR)")

cmd/root/run.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,10 @@ func (f *runExecFlags) createRemoteRuntimeAndSession(ctx context.Context, origin
181181
return nil, nil, fmt.Errorf("failed to create remote client: %w", err)
182182
}
183183

184-
sessTemplate := session.New()
185-
sessTemplate.ToolsApproved = f.autoApprove
184+
sessTemplate := session.New(
185+
session.WithToolsApproved(f.autoApprove),
186+
)
187+
186188
sess, err := remoteClient.CreateSession(ctx, sessTemplate)
187189
if err != nil {
188190
return nil, nil, err
@@ -206,14 +208,14 @@ func (f *runExecFlags) createLocalRuntimeAndSession(t *team.Team) (runtime.Runti
206208
return nil, nil, err
207209
}
208210

209-
sess := session.New(session.WithMaxIterations(agent.MaxIterations()))
210-
sess.ToolsApproved = f.autoApprove
211-
212-
tracer := otel.Tracer(AppName)
211+
sess := session.New(
212+
session.WithMaxIterations(agent.MaxIterations()),
213+
session.WithToolsApproved(true),
214+
)
213215

214216
localRt, err := runtime.New(t,
215217
runtime.WithCurrentAgent(f.agentName),
216-
runtime.WithTracer(tracer),
218+
runtime.WithTracer(otel.Tracer(AppName)),
217219
runtime.WithRootSessionID(sess.ID),
218220
)
219221
if err != nil {

docs/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ task build
2727
export OPENAI_API_KEY=your_api_key_here # For OpenAI models
2828
export ANTHROPIC_API_KEY=your_api_key_here # For Anthopic models
2929
export GOOGLE_API_KEY=your_api_key_here # For Gemini models
30+
export MISTRAL_API_KEY=your_api_key_here # For Mistral models
3031

3132
# Run with a sample configuration
3233
./bin/cagent run examples/code.yaml

pkg/agent/agent.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ func (a *Agent) Model() provider.Provider {
9797
return a.models[rand.Intn(len(a.models))]
9898
}
9999

100+
// Commands returns the named commands configured for this agent.
101+
func (a *Agent) Commands() map[string]string {
102+
return a.commands
103+
}
104+
100105
// Tools returns the tools available to this agent
101106
func (a *Agent) Tools(ctx context.Context) ([]tools.Tool, error) {
102107
a.ensureToolSetsAreStarted(ctx)
@@ -131,11 +136,6 @@ func (a *Agent) ToolSets() []tools.ToolSet {
131136
return toolSets
132137
}
133138

134-
// Commands returns the named commands configured for this agent.
135-
func (a *Agent) Commands() map[string]string {
136-
return a.commands
137-
}
138-
139139
func (a *Agent) ensureToolSetsAreStarted(ctx context.Context) {
140140
for _, toolSet := range a.toolsets {
141141
// Skip if toolset is already started

pkg/aliases/aliases.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ func loadFrom(path string) (*Aliases, error) {
3232
return nil, fmt.Errorf("failed to read aliases file: %w", err)
3333
}
3434

35-
s := Aliases{}
36-
if err := yaml.Unmarshal(data, &s); err != nil {
35+
var aliases Aliases
36+
if err := yaml.Unmarshal(data, &aliases); err != nil {
3737
return nil, fmt.Errorf("failed to parse aliases file: %w", err)
3838
}
3939

40-
return &s, nil
40+
return &aliases, nil
4141
}
4242

4343
// Save saves aliases to the configuration file

pkg/cli/text.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ func (p *Printer) PrintToolCallResponse(toolCall tools.ToolCall, response string
135135
// PromptMaxIterationsContinue prompts the user to continue after max iterations
136136
func (p *Printer) PromptMaxIterationsContinue(ctx context.Context, maxIterations int) ConfirmationResult {
137137
p.Printf("\n⚠️ Maximum iterations (%d) reached. The agent may be stuck in a loop.\n", maxIterations)
138-
p.Printf("%s\n", "This can happen with smaller or less capable models.")
139-
p.Printf("\n%s (y/n): ", "Do you want to continue for 10 more iterations?")
138+
p.Println("This can happen with smaller or less capable models.")
139+
p.Println("\nDo you want to continue for 10 more iterations? (y/n):")
140140

141141
response, err := input.ReadLine(ctx, os.Stdin)
142142
if err != nil {
@@ -164,7 +164,7 @@ func (p *Printer) PromptOAuthAuthorization(ctx context.Context, serverURL string
164164

165165
response, err := input.ReadLine(ctx, os.Stdin)
166166
if err != nil {
167-
p.Printf("\n%s\n", "Failed to read input, aborting authorization...")
167+
p.Println("\nFailed to read input, aborting authorization...")
168168
return ConfirmationAbort
169169
}
170170

pkg/config/config_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ func TestCheckRequiredEnvVars(t *testing.T) {
214214
yaml: "google_inline.yaml",
215215
expectedMissing: []string{"GOOGLE_API_KEY"},
216216
},
217+
{
218+
yaml: "mistral_inline.yaml",
219+
expectedMissing: []string{"MISTRAL_API_KEY"},
220+
},
217221
{
218222
yaml: "dmr_inline.yaml",
219223
expectedMissing: []string{},
@@ -230,13 +234,17 @@ func TestCheckRequiredEnvVars(t *testing.T) {
230234
yaml: "google_model.yaml",
231235
expectedMissing: []string{"GOOGLE_API_KEY"},
232236
},
237+
{
238+
yaml: "mistral_model.yaml",
239+
expectedMissing: []string{"MISTRAL_API_KEY"},
240+
},
233241
{
234242
yaml: "dmr_model.yaml",
235243
expectedMissing: []string{},
236244
},
237245
{
238246
yaml: "all.yaml",
239-
expectedMissing: []string{"ANTHROPIC_API_KEY", "GOOGLE_API_KEY", "OPENAI_API_KEY"},
247+
expectedMissing: []string{"ANTHROPIC_API_KEY", "GOOGLE_API_KEY", "MISTRAL_API_KEY", "OPENAI_API_KEY"},
240248
},
241249
}
242250
for _, test := range tests {

pkg/config/gather.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func GatherEnvVarsForModels(cfg *latest.Config) []string {
6565
requiredEnv["ANTHROPIC_API_KEY"] = true
6666
case "google":
6767
requiredEnv["GOOGLE_API_KEY"] = true
68+
case "mistral":
69+
requiredEnv["MISTRAL_API_KEY"] = true
6870
}
6971
}
7072
}

pkg/config/testdata/env/all.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ agents:
1313
gemini:
1414
model: google/gemini-2.0-flash
1515
instruction: Always answer by talking like a pirate.
16+
mistral:
17+
model: mistral/mistral-small-latest
18+
instruction: Always answer by talking like a pirate.

0 commit comments

Comments
 (0)