Skip to content

feat: add --prompt flag for foreground agent mode#454

Merged
mudler merged 2 commits intomudler:mainfrom
localai-bot:feat-foreground-prompt
Mar 11, 2026
Merged

feat: add --prompt flag for foreground agent mode#454
mudler merged 2 commits intomudler:mainfrom
localai-bot:feat-foreground-prompt

Conversation

@localai-bot
Copy link
Copy Markdown
Contributor

Summary

Implements a new foreground mode for the local-agi agent run command that:

  • Accepts a --prompt flag with a message
  • Creates the agent, runs it with Ask(prompt), collects the output, and prints it to stdout
  • Exits after the operation completes (no background process)

Usage

# Run with agent name
local-agi agent run my-agent --prompt "whatever"

# Run with JSON config file
local-agi agent run --config agent.json --prompt "whatever"

Implementation

  • Added --prompt/-p flag to the agent run subcommand
  • New runAgentForeground function handles single-prompt execution
  • Follows existing code patterns in cmd/agent_run.go
  • Uses types.WithText() to pass the prompt to the agent's Ask() method

- Add --prompt/-p flag to 'agent run' command
- When --prompt is provided, runs agent in foreground mode
- Creates agent, executes Ask() with the prompt, prints response, and exits
- Supports both agent name and --config file input modes
- Follows existing code patterns in the repository
Copy link
Copy Markdown
Owner

@mudler mudler left a comment

Choose a reason for hiding this comment

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

The changes direction looks good, have to fix CI.

@mudler mudler merged commit 2d2da7d into mudler:main Mar 11, 2026
1 of 2 checks passed
@localai-bot
Copy link
Copy Markdown
Contributor Author

The CI failure in test-e2e appears to be unrelated to the code changes in this PR. The implementation correctly uses result.Error != nil and result.Response as defined in the JobResult struct. The e2e test failure (42m timeout) seems to be an infrastructure or test environment issue. The main 'test' job passes successfully. Could you please investigate if this is a flaky test or environment issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants