Skip to main content

generate_commit_message

Function generate_commit_message 

Source
pub fn generate_commit_message(
    diff: &str,
    registry: &AgentRegistry,
    runtime: &mut PipelineRuntime<'_>,
    commit_agent: &str,
    template_context: &TemplateContext,
    workspace: &dyn Workspace,
    prompt_history: &HashMap<String, String>,
) -> Result<CommitMessageResult>
Expand description

Generate a commit message using a single agent attempt.

Returns an error if XML validation fails or the agent output is missing.

§Truncation Behavior (CLI vs Reducer)

IMPORTANT: This function uses single-agent budget for truncation, which differs from the reducer-driven path that uses chain-minimum budget.

PathBudget CalculationWhen Used
CLI (--generate-commit-msg)model_budget_bytes_for_agent_name(agent)Single agent, no fallback chain
Reducer (MaterializeCommitInputs)effective_model_budget_bytes(&agents)Agent chain with potential fallbacks

Why this is acceptable:

  • CLI plumbing commands (--generate-commit-msg) invoke a single, explicitly-specified agent with no fallback chain. There’s no need to compute min budget across agents.
  • The reducer path handles multi-agent chains where the diff must fit the smallest agent’s context window to ensure fallback attempts can succeed.

Implication: A diff that works via CLI might fail via reducer if the chain includes an agent with a smaller budget. This is by design - the CLI user explicitly chose the agent and accepts its budget constraints.