Skip to content

fix: respect explicit mode input instead of always auto-detecting#1198

Open
FuturizeRush wants to merge 1 commit intoanthropics:mainfrom
FuturizeRush:fix/respect-explicit-mode-input
Open

fix: respect explicit mode input instead of always auto-detecting#1198
FuturizeRush wants to merge 1 commit intoanthropics:mainfrom
FuturizeRush:fix/respect-explicit-mode-input

Conversation

@FuturizeRush
Copy link
Copy Markdown

Summary

When users set mode: agent in their workflow, the action ignores it and exits with "No trigger found, skipping." This PR makes the explicit mode input actually work.

Fixes #1197

Root cause

  1. action.yml:246 sets MODE=${{ inputs.mode }} as an env var
  2. detectMode() in src/modes/detector.ts never reads process.env.MODE — it only auto-detects from event context
  3. Trigger check (run.ts:194-197) requires context.inputs.prompt to be truthy for agent mode, but users using direct_prompt have an empty promptcontainsTrigger = false → skip

process.env.MODE is set but never read anywhere in the codebase.

Fix

Two changes in src/entrypoints/run.ts:

  1. Check process.env.MODE before calling detectMode() — if explicitly "agent" or "tag", use it directly instead of auto-detecting
  2. Bypass trigger detection when mode is explicit — the user opted in by setting mode, so no trigger check is needed

What changes

Scenario Before After
mode: agent + direct_prompt "No trigger found, skipping" Runs Claude
mode: agent + prompt "No trigger found, skipping" (if no entity context) Runs Claude
mode: tag (explicit) Auto-detected as tag (worked by coincidence) Explicitly tag
No mode set Auto-detect Auto-detect (unchanged)

Test plan

  • TypeScript compiles with zero errors (npx tsc --noEmit)
  • Traced the full code path: action.yml:246process.env.MODErun.ts:156detectMode() confirms MODE is never read
  • Confirmed base-action/src/index.ts already handles mode correctly (this fix aligns run.ts with that behavior)

When users set `mode: agent` (or `mode: tag`) in their workflow,
the action ignored it — detectMode() never reads process.env.MODE,
and the trigger check still required context.inputs.prompt to be
truthy. This caused agent-mode workflows using direct_prompt to
exit with "No trigger found, skipping".

Now process.env.MODE is checked first. When explicitly set:
- It overrides auto-detection from detectMode()
- Trigger detection is bypassed (user opted in by setting mode)

Fixes anthropics#1197
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.

mode: agent does not bypass trigger detection in beta — exits with 'No trigger found, skipping'

1 participant