Skip to content

Agent loops after providing answer in non-interactive modes (interactive: false or direct CLI prompt) #403

Open
@BearThreat

Description

@BearThreat

When MyCoder is run with interactive: false in the configuration, or when a prompt is provided directly via the CLI (e.g., mycoder "some prompt"), the agent correctly processes the request and provides an initial answer. However, instead of exiting cleanly, it enters an indefinite loop, repeatedly generating follow-up messages asking for confirmation or if further assistance is needed. The process does not terminate on its own and requires manual intervention (Ctrl+C or kill when using mycoder -i).

This behavior is observed even for simple, non-tool-intensive tasks (e.g., "What is the capital of France?") and persists whether profile is true or false.

Environment:

  • MyCoder Version: Installed via npm install -g mycoder
  • Node.js Version: v22.16.0 (npm v10.9.2) (Managed via NVM for Linux)
  • Operating System: Windows 10 with WSL2
  • WSL Distro: Ubuntu
  • Terminal: VSCode Integrated Terminal
  • Git Version: git version 2.34.1
  • GitHub CLI Version: gh version 2.4.0+dfsg1

mycoder.config.js:

// mycoder.config.js
export default {
  githubMode: false,

  // Browser settings (loop observed even without browser tasks)
  headless: true,
  userSession: false,
  browser: {
    useSystemBrowsers: false,
    preferredType: 'chromium',
    executablePath: null,
  },

  // Model settings (Ollama proxy to OpenRouter)
  provider: 'ollama',
  model: 'openai/gpt-4o', // Also observed with 'anthropic/claude-sonnet-4' via proxy
  baseUrl: 'http://localhost:11434', // Ollama-compatible OpenRouter proxy

  // Core issue observed with these settings
  interactive: false,
  profile: false, // Also observed with profile: true

  customPrompt: [],
  mcp: { servers: [] },
};

Steps to Reproduce:

  1. Set up mycoder.config.js as shown above.
  2. Ensure an Ollama-compatible proxy (e.g., to OpenRouter) is running and accessible at baseUrl.
  3. Run MyCoder with a simple prompt directly on the command line:
    mycoder "What is the capital of France?"
  4. Alternatively, run mycoder -i and enter the same prompt. Ensure interactive: false is in the config.

Expected Behavior:
The agent should provide the answer (e.g., "The capital of France is Paris.") and then terminate the process cleanly without further interaction, especially when a prompt is given directly on the CLI.

Actual Behavior:
The agent provides the correct answer, then enters a loop. Example output snippet:

The capital of France is Paris.
Please let me know if this answer is acceptable, or if you need any changes or additional information.
I understand this is the correct information for your inquiry. If you have more questions, need further assistance, or would like further clarifications, feel free to let me know!
I hope this answer meets your expectations. If there is anything else you need or any follow-up questions you might have, feel free to ask!
... (continues until manually terminated with Ctrl+C or kill) ...

The process consumes resources and generates extensive token usage due to the loop.

Additional Notes:

  • Ctrl+C works to terminate the process when run as mycoder "prompt".
  • Ctrl+C does not reliably work when run in mycoder -i shell mode (requires kill from another terminal). This might be a separate TTY/signal handling issue within the -i mode.
  • The Ollama OpenRouter proxy backend (using https://github.com/xsharov/enchanted-ollama-openrouter-proxy) appears to be functioning correctly as the initial answer is accurate. The issue seems to be in MyCoder's agent logic for task completion in non-interactive scenarios.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions