A team wants a monitor job to summarize multi-agent execution results after validation and documentation jobs finish. The monitor should still run when one upstream job fails, but it should not run if the workflow is cancelled. The summary should record each upstream job result. Which option completes the workflow?
name: multi-agent-monitor
on:
pull_request:
branches:
- main
jobs:
validation-agent:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm test
docs-agent:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm run docs:check
monitor-agent:
runs-on: ubuntu-latest
needs:
- validation-agent
- docs-agent
if: (Missing value 1)
steps:
- name: Write coordination summary
run: |
echo "validation=${{ (Missing value 2) }}" >> agent-summary.txt
echo "docs=${{ (Missing value 3) }}" >> agent-summary.txtChoose an answer
Tap an option to check your answer.
Correct answer: Missing value 1 = ${{ !cancelled() }} Missing value 2 = needs.validation-agent.result Missing value 3 = needs.docs-agent.result.
Why this is the answer
The correct option ensures the monitor-agent job runs conditionally and accurately reports upstream job results. if: ${{ !cancelled() }} prevents the monitor from running if the workflow is canceled, fulfilling the requirement. needs.validation-agent.result and needs.docs-agent.result correctly access the final outcome (success, failure, or skipped) of the specified upstream jobs. The needs context is specifically designed to retrieve information about dependent jobs. Incorrect options: success() would prevent the monitor from running if any upstream job failed, which contradicts the requirement that it should still run. always() would cause the monitor to run even if the workflow was canceled, which is not desired. failure() would only run the monitor if an upstream job failed, not if they all succeeded. job.validation-agent.status and steps.validation-agent.outcome are not valid ways to access job results across different jobs in the needs context. github.validation.result is also an invalid context reference.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed