feat(agents): context compaction (budget notices, mid-turn floor, background compaction) #3430
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: TS tests | |
| on: | |
| push: | |
| branches: ['main'] | |
| paths-ignore: | |
| - 'website/**' | |
| - '**/README.md' | |
| - 'integration-tests/**' | |
| pull_request: | |
| paths-ignore: | |
| - 'website/**' | |
| - '**/README.md' | |
| - 'integration-tests/**' | |
| permissions: | |
| contents: read | |
| packages: read | |
| jobs: | |
| detect_affected_workspaces: | |
| name: Detect affected TS workspaces | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| outputs: | |
| package_directories: ${{ steps.detect.outputs.package_directories }} | |
| packages_with_shared_sync_service: ${{ steps.detect.outputs.packages_with_shared_sync_service }} | |
| packages_without_shared_sync_service: ${{ steps.detect.outputs.packages_without_shared_sync_service }} | |
| example_directories: ${{ steps.detect.outputs.example_directories }} | |
| has_packages: ${{ steps.detect.outputs.has_packages }} | |
| has_shared_sync_service_packages: ${{ steps.detect.outputs.has_shared_sync_service_packages }} | |
| has_non_shared_sync_service_packages: ${{ steps.detect.outputs.has_non_shared_sync_service_packages }} | |
| has_examples: ${{ steps.detect.outputs.has_examples }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.tool-versions' | |
| - name: Detect affected workspaces | |
| id: detect | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} | |
| run: node scripts/ci/affected-workspaces.mjs | |
| typecheck_packages: | |
| name: Build and typecheck ${{ matrix.package_dir }} | |
| needs: [detect_affected_workspaces] | |
| if: ${{ needs.detect_affected_workspaces.outputs.has_packages == 'true' }} | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| package_dir: ${{ fromJson(needs.detect_affected_workspaces.outputs.package_directories) }} | |
| defaults: | |
| run: | |
| working-directory: ${{ matrix.package_dir }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.tool-versions' | |
| cache: 'pnpm' | |
| - run: pnpm --filter "$(jq -r .name package.json)..." install --frozen-lockfile | |
| - run: pnpm -r --filter "$(jq '.name' -r package.json)^..." build | |
| - run: pnpm run typecheck | |
| - name: Run shape stream static analysis | |
| if: ${{ matrix.package_dir == 'packages/typescript-client' }} | |
| run: pnpm run analyze:shape-stream -- --fail-on-findings | |
| ensure_sync_service_image: | |
| needs: [detect_affected_workspaces] | |
| if: ${{ needs.detect_affected_workspaces.outputs.has_shared_sync_service_packages == 'true' }} | |
| # Reusable workflow pushes to GHCR; scope packages: write here since it can't | |
| # exceed the caller token (top-level stays read, see #4450). | |
| permissions: | |
| contents: read | |
| packages: write | |
| uses: ./.github/workflows/ensure_sync_service_image.yml | |
| build_and_test_packages_with_shared_sync_service: | |
| name: 'Test ${{ matrix.package_dir }} w/ sync-service' | |
| needs: [detect_affected_workspaces, ensure_sync_service_image] | |
| if: ${{ needs.detect_affected_workspaces.outputs.has_shared_sync_service_packages == 'true' }} | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| package_dir: ${{ fromJson(needs.detect_affected_workspaces.outputs.packages_with_shared_sync_service) }} | |
| defaults: | |
| run: | |
| working-directory: ${{ matrix.package_dir }} | |
| env: | |
| ELECTRIC_IMAGE: ${{ needs.ensure_sync_service_image.outputs.image }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.tool-versions' | |
| cache: pnpm | |
| - name: Install Node dependencies | |
| run: pnpm --filter "$(jq -r .name package.json)..." install --frozen-lockfile | |
| - name: Build Node dependencies, if any | |
| run: pnpm -r --filter "$(jq '.name' -r package.json)^..." build | |
| - name: Run Postgres, Electric and nginx for the subsequent test suite | |
| working-directory: packages/sync-service/dev | |
| run: | | |
| docker compose -f docker-compose.yml -f docker-compose-electric.yml up --wait postgres electric nginx | |
| - name: Run tests with coverage | |
| run: pnpm run coverage --run | |
| - name: Upload coverage reports to CodeCov | |
| uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: typescript,unit-tests,${{ matrix.package_dir }} | |
| - name: Upload test results to CodeCov | |
| uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 | |
| if: ${{ !cancelled() }} | |
| env: | |
| DUMMY_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}-dummy | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| flags: typescript,unit-tests,${{ matrix.package_dir }} | |
| files: ./junit/test-report.junit.xml | |
| build_and_test_packages_without_shared_sync_service: | |
| name: 'Test ${{ matrix.package_dir }}' | |
| needs: [detect_affected_workspaces] | |
| if: ${{ needs.detect_affected_workspaces.outputs.has_non_shared_sync_service_packages == 'true' }} | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| # agents-runtime integration tests boot and migrate an isolated Electric Agents | |
| # backend, then run with V8 coverage enabled. On CI this can exceed 10m. | |
| timeout-minutes: 20 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| package_dir: ${{ fromJson(needs.detect_affected_workspaces.outputs.packages_without_shared_sync_service) }} | |
| defaults: | |
| run: | |
| working-directory: ${{ matrix.package_dir }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.tool-versions' | |
| cache: pnpm | |
| - name: Install Node dependencies | |
| run: | | |
| package_name="$(jq -r .name package.json)" | |
| if [ "$package_name" = "@electric-ax/agents-runtime" ]; then | |
| pnpm --filter "$package_name..." --filter "@electric-ax/agents-server..." install --frozen-lockfile | |
| else | |
| pnpm --filter "$package_name..." install --frozen-lockfile | |
| fi | |
| - name: Build Node dependencies, if any | |
| run: pnpm -r --filter "$(jq '.name' -r package.json)^..." build | |
| - name: Run tests with coverage | |
| run: pnpm run coverage --run | |
| - name: Upload coverage reports to CodeCov | |
| uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: typescript,unit-tests,${{ matrix.package_dir }} | |
| - name: Upload test results to CodeCov | |
| uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 | |
| if: ${{ !cancelled() }} | |
| env: | |
| DUMMY_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}-dummy | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| flags: typescript,unit-tests,${{ matrix.package_dir }} | |
| files: ./junit/test-report.junit.xml | |
| check_and_build_examples: | |
| name: Check and build ${{ matrix.example_folder }} | |
| needs: | |
| [ | |
| detect_affected_workspaces, | |
| build_and_test_packages_with_shared_sync_service, | |
| build_and_test_packages_without_shared_sync_service, | |
| ] | |
| if: ${{ always() && needs.detect_affected_workspaces.outputs.has_examples == 'true' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| example_folder: ${{ fromJson(needs.detect_affected_workspaces.outputs.example_directories) }} | |
| defaults: | |
| run: | |
| working-directory: ${{ matrix.example_folder }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.tool-versions' | |
| cache: pnpm | |
| - run: pnpm --filter "$(jq -r .name package.json)..." --filter @electric-examples/shared install --frozen-lockfile | |
| - run: pnpm -r --filter "$(jq '.name' -r package.json)^..." build | |
| - run: pnpm --if-present run prepare | |
| - run: pnpm --if-present run typecheck | |
| - run: pnpm --if-present run build | |
| - run: pnpm --if-present run test --run |