Skip to content

[q] Fix ambient context analysis to use API proxy event log #37652

@github-actions

Description

@github-actions

Q Workflow Optimization Report

Triggered by @pelikhan on issue #37647.

Investigation Findings (from live data)

daily-ambient-context-optimizer

Finding 1 — Inline agents ARE compiler-stripped

linter-miner.md source has 3 inline ## agent: blocks. Its compiled prompt.txt has 0 inline agent headers. The compiler strips them before the first LLM request. The prior report's R5 recommendation ("extract linter-writer agent body") was a false positive.

Finding 2 — prompt.txt IS the API proxy first request

Cross-validated against token-usage.jsonl:

  • Design Decision Gate: prompt.txt = 35,002 chars; first entry = 13,911 tokens × ~2.5 ≈ 34,778 chars ✅
  • Documentation Unbloat: prompt.txt = 18,942 chars; first entry = 7,527 tokens × ~2.5 ≈ 18,818 chars ✅

Finding 3 — events.jsonl user.message data field is empty

Cannot be used as text source. The fallback path in the workflow was also incomplete (missing */ glob segment).

Finding 4 — Misleading Source Review guidance

The Source Review section listed "too many inline agents" as a size driver and Recommendation Rules priority #3 said to "remove low-value inline agents" — both wrong since inline agents are compiler-stripped.

Changes Made

.github/workflows/daily-ambient-context-optimizer.md

  1. Eligibility rules: Fixed events.jsonl path to include full glob; added note that prompt.txt is post-compilation with inline agents stripped.
  2. First-Request Extraction Rules: Added compilation bug check (flag ## agent:/## skill: in prompt.txt); added token-usage.jsonl cross-validation; added first_request_input_tokens and compilation_bug fields to metadata JSON.
  3. Deterministic Analysis: Inline agent/skill counts now flagged as compilation bugs; bug-flagged content excluded from size measurements.
  4. Source Review: Removed "too many inline agents" as size driver; replaced with "large imported agent definitions" (via imports: — these ARE inlined); added compiler-strip explanation and bug-flagging guidance.
  5. Recommendation Rules priority Add workflow: githubnext/agentics/weekly-research #3: Changed from "remove low-value inline agents" to "trim large imported agent definitions" with compiler-strip explanation.

Expected Improvements

  • Eliminates false "too many inline agents" recommendations in future reports
  • Detects real compilation bugs if inline agents ever leak into prompt.txt
  • Adds token-count cross-validation for size accuracy
  • Fixes incomplete events.jsonl path in fallback rule

Validation

  • daily-ambient-context-optimizer — compiled valid: true, errors: [], warnings: []

Note: .lock.yml will be regenerated automatically after merge.

References


Warning

Protected Files — Push Permission Denied

This was originally intended as a pull request, but the patch modifies protected files. A human must create the pull request manually.

Protected files

The push was rejected because GitHub Actions does not have workflows permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.

Create the pull request manually
# Download the patch from the workflow run
gh run download 27103739370 -n agent -D /tmp/agent-27103739370

# Create a new branch
git checkout -b q/fix-ambient-context-optimizer-analysis-source-193317c01f5f7a60 main

# Apply the patch (--3way handles cross-repo patches)
git am --3way /tmp/agent-27103739370/aw-q-fix-ambient-context-optimizer-analysis-source.patch

# Push the branch and create the pull request
git push origin q/fix-ambient-context-optimizer-analysis-source-193317c01f5f7a60
gh pr create --title '[q] Fix ambient context analysis to use API proxy event log' --base main --head q/fix-ambient-context-optimizer-analysis-source-193317c01f5f7a60 --repo github/gh-aw

🎩 Equipped by Q · sonnet46 831.8K · ⌖ 23.4 AIC ·

  • expires on Jun 9, 2026, 12:50 PM UTC-08:00

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions