mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-12-03 02:50:29 +01:00
56 lines
2.5 KiB
YAML
56 lines
2.5 KiB
YAML
name: Agent Context Budget
|
|
|
|
# Fails when a PR raises a value in agentContextBudget.json above main's. AgentContextBudget.test.ts
|
|
# keeps that file equal to the measured context, so the context cannot grow by editing the file.
|
|
# To accept growth on purpose, a maintainer adds the agent-context-increase label.
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, labeled, unlabeled]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# No concurrency group: label events arrive in bursts, and a cancelled run reports as a failed check.
|
|
jobs:
|
|
budget:
|
|
name: Agent context budget
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 5
|
|
env:
|
|
BUDGET: apps/server/src/provider/agentContextBudget.json
|
|
ALLOW_INCREASE: ${{ contains(github.event.pull_request.labels.*.name, 'agent-context-increase') }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
|
with:
|
|
sparse-checkout: apps/server/src/provider/agentContextBudget.json
|
|
sparse-checkout-cone-mode: false
|
|
fetch-depth: 2
|
|
|
|
# The checkout is the PR merged onto main; compare with that merge's main parent. A fresh
|
|
# fetch of main can be newer and lower, which reports the PR as growing what main just cut.
|
|
- name: Compare with main
|
|
# HEAD is the PR merge commit; its first parent is the main it was built on. A freshly
|
|
# fetched main can hold lower values the PR never saw, which would read as growth.
|
|
run: |
|
|
if ! git cat-file -e "HEAD^1:$BUDGET" 2>/dev/null; then
|
|
echo "main has no agent context budget yet."
|
|
exit 0
|
|
fi
|
|
git show "HEAD^1:$BUDGET" > "$RUNNER_TEMP/main.json"
|
|
grown=$(jq -r --slurpfile main "$RUNNER_TEMP/main.json" '
|
|
to_entries[]
|
|
| select($main[0][.key] != null and .value > $main[0][.key])
|
|
| "\(.key): \($main[0][.key]) -> \(.value) (+\(.value - $main[0][.key]))"
|
|
' "$BUDGET")
|
|
if [ -z "$grown" ]; then
|
|
echo "Agent context is not larger than main."
|
|
exit 0
|
|
fi
|
|
printf 'Agent context grew compared to main:\n%s\n' "$grown"
|
|
if [ "$ALLOW_INCREASE" = "true" ]; then
|
|
echo "Accepted by the agent-context-increase label."
|
|
exit 0
|
|
fi
|
|
echo "::error file=$BUDGET::Agent context grew compared to main. Cut the added text and rerun the evals that cover it (evals/README.md), or ask a maintainer to add the agent-context-increase label."
|
|
exit 1
|