Skip to content

Non-interactive mode (-P) bypasses systemPromptAdditions and projectContext #266

@laynepenney

Description

@laynepenney

Problem

The handle_prompt() function in main.rs (the -P / --prompt non-interactive path) manually constructs an AgentConfig and uses a hardcoded system prompt:

system_prompt: Some("You are Codi, a helpful AI coding assistant.".to_string()),

This means systemPromptAdditions and projectContext from .codi.json are ignored when running in non-interactive mode, even though the ResolvedConfig is available and other config fields (auto_approve, no_tools, max_context_tokens, etc.) are correctly wired.

Expected Behavior

-P mode should use the same build_system_prompt() logic as the interactive TUI, incorporating:

  • config.system_prompt_additions
  • config.project_context

Proposed Fix

Extract the system prompt building logic from App::build_system_prompt() into a standalone function (or a method on ResolvedConfig) so both run_repl and handle_prompt can share it. For example:

fn build_system_prompt(config: &ResolvedConfig) -> String {
    let mut prompt = "You are Codi, a helpful AI coding assistant.".to_string();
    if let Some(ref additions) = config.system_prompt_additions {
        prompt.push_str("\n\n");
        prompt.push_str(additions);
    }
    if let Some(ref ctx) = config.project_context {
        prompt.push_str("\n\n## Project Context\n");
        prompt.push_str(ctx);
    }
    prompt
}

Related

PR #261 — Wire config options, context compaction, and auto-index on startup
#262with_provider/with_provider_and_path bypass config wiring (same category of issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions