serverless/serverless · error · ServerlessError
LOGS_MUTUAL_EXCLUSIVITY
LOGS_MUTUAL_EXCLUSIVITY
Error message
Cannot specify both --function and --agent. Use --function to view Lambda function logs or --agent to view agent logs.
What it means
Error "Cannot specify both --function and --agent. Use --function to view Lambda function logs or --agent to view agent logs." thrown in serverless/serverless.
Source
Thrown at packages/serverless/lib/plugins/aws/logs-agent.js:29
* Plugin for viewing CloudWatch logs from AgentCore Runtime agents.
* Follows the same pattern as invoke-agent.js for the invoke command.
*/
class AwsLogsAgent {
constructor(serverless, options, pluginUtils) {
this.serverless = serverless
this.options = options || {}
this.provider = this.serverless.getProvider('aws')
this.logger = pluginUtils.log
this.progress = pluginUtils.progress
this.hooks = {
'logs:logs': async () => {
if (!this.options.agent) {
return
}
if (this.options.function) {
throw new ServerlessError(
'Cannot specify both --function and --agent. Use --function to view Lambda function logs or --agent to view agent logs.',
'LOGS_MUTUAL_EXCLUSIVITY',
)
}
if (!this.options.tail) {
this.progress.notice('Fetching agent logs')
} else {
this.logger.aside(
`Streaming new logs for agent: "${this.options.agent}"`,
)
this.progress.notice('Listening')
}
this.validateAgent()
this.options.interval = this.options.interval || 1000
this.options.logGroupName = await this.resolveLogGroupName()
const logStreamNames = await this.getLogStreams()View on GitHub (pinned to b9d7ea51c8)
Solutions
- Use either --function to view Lambda logs or --agent to view agent logs, but not both in the same command.
When it happens
Trigger: Thrown at packages/serverless/lib/plugins/aws/logs-agent.js:29 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of serverless/serverless@b9d7ea51c8 (2026-08-13).
Data as JSON: /api/errors/59d8c56596f75c82.
Report an issue: GitHub.