Skip to content

feat(agents): add max_concurrent_agent_runs to YAML config and API - #9444

Open
Ilya Matiach (imatiach-msft) wants to merge 1 commit into
Azure:mainfrom
imatiach-msft:feat/agents-max-concurrent-agent-runs
Open

feat(agents): add max_concurrent_agent_runs to YAML config and API#9444
Ilya Matiach (imatiach-msft) wants to merge 1 commit into
Azure:mainfrom
imatiach-msft:feat/agents-max-concurrent-agent-runs

Conversation

@imatiach-msft

Copy link
Copy Markdown
Contributor

Problem

Evaluating large datasets sequentially takes O(n x t) time and frequently hits the 6-hour FAOS job timeout. The evaluation service already supports parallel agent invocations via the item_generation_params.max_concurrency field on the azure_ai_target_completions data source, but there was no way to set this from the optimize YAML config.

Without this, a 300-row evaluation with ~30s/row takes ~150 minutes sequentially, exceeding the timeout. With max_concurrent_agent_runs: 8 it should take ~19 minutes.

Change

Mirrors the pattern introduced for max_stalls in #9314. YAML-only, no CLI flag.

Changes:

  1. opt_eval.Options struct (yaml.go) - YAML key max_concurrent_agent_runs
  2. optimize_api.OptimizeOptions struct (models.go) - JSON key max_concurrent_agent_runs
  3. OptimizeConfig.ToRequest() (optimize_config.go) - forwarded to API
  4. OptimizeConfig.Validate() - rejects values < 1

Usage

options:
eval_model: gpt-4.1
optimization_model: gpt-5
max_concurrent_agent_runs: 8

Tests

8 new tests: YAML parsing (present/absent), Validate rejection of 0, Validate acceptance of positive values, ToRequest forwarding, ToRequest nil when omitted.

Mirrors the pattern introduced for max_stalls in Azure#9314.

## Problem

Evaluating large datasets sequentially takes O(n×t) time and frequently
hits the 6-hour FAOS job timeout. The evaluation service already
supports parallel agent invocations via the
\item_generation_params.max_concurrency\ field in the
\�zure_ai_target_completions\ data source, but there was no way to
set this from the optimize YAML config.

## Change

Add \max_concurrent_agent_runs\ (YAML-only, no CLI flag, following the
same policy as \max_stalls\) to:

1. \opt_eval.Options\ struct (yaml.go) — YAML key \max_concurrent_agent_runs\
2. \optimize_api.OptimizeOptions\ struct (models.go) — JSON key \max_concurrent_agent_runs\
3. \OptimizeConfig.ToRequest()\ (optimize_config.go) — forwarded to API
4. \OptimizeConfig.Validate()\ — rejects values < 1

## Usage

\\\yaml
options:
  eval_model: gpt-4.1
  optimization_model: gpt-5
  max_concurrent_agent_runs: 8   # run 8 agent calls in parallel per eval
\\\

## Tests

8 new tests covering: YAML parsing (present/absent), Validate rejection
of 0, Validate acceptance of positive values, ToRequest forwarding to
API, ToRequest nil when omitted.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
19 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported identify a customer issue label Aug 5, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution Ilya Matiach (@imatiach-msft)! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Repository lint/convention violations and missing API serialization coverage should be addressed.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds YAML-configurable concurrency for agent optimization evaluations and forwards it to the service API.

Changes:

  • Adds max_concurrent_agent_runs to YAML and API models.
  • Validates positive values and forwards the setting.
  • Adds parsing, validation, and forwarding tests.
File summaries
File Description
internal/pkg/agents/optimize_api/models.go Adds the API request field.
internal/pkg/agents/opt_eval/yaml.go Adds the YAML option.
internal/pkg/agents/opt_eval/yaml_test.go Tests YAML parsing and omission.
internal/cmd/optimize_config.go Validates and forwards concurrency.
internal/cmd/optimize_config_test.go Tests validation and request mapping.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.


if c.Options.MaxConcurrentAgentRuns != nil && *c.Options.MaxConcurrentAgentRuns < 1 {
return fmt.Errorf(
"options.max_concurrent_agent_runs must be >= 1 (got %d): set 'max_concurrent_agent_runs' under 'options:' in your config file",
Comment on lines +461 to +471
n := 8
cfg := &OptimizeConfig{
Config: opt_eval.Config{
Agent: opt_eval.AgentRef{Name: "agent"},
Evaluators: opt_eval.EvaluatorList{{Name: "builtin.task_adherence"}},
DatasetFile: writeTestFile(t, dir, "ds.jsonl", `{"query":"hi"}`),
},
Options: &opt_eval.Options{
EvalModel: "gpt-4o-mini",
OptimizationModel: "gpt-5",
MaxConcurrentAgentRuns: &n,
MaxStalls *int `json:"max_stalls,omitempty"`
// MaxConcurrentAgentRuns is the maximum number of agent invocations the
// evaluation service executes concurrently. Omitted when nil (service default applies).
MaxConcurrentAgentRuns *int `json:"max_concurrent_agent_runs,omitempty"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported identify a customer issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants