-
Notifications
You must be signed in to change notification settings - Fork 2
140 lines (128 loc) · 5.24 KB
/
agent-memory-scan.yml
File metadata and controls
140 lines (128 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Agent / Memory / Curate Recent Activity
on:
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
inputs:
memory_ref:
description: "Memory branch to update"
required: false
default: agent/memory
permissions:
contents: write
issues: read
pull-requests: read
discussions: read
id-token: write # required for GitHub Actions OIDC broker exchange
concurrency:
group: agent-memory-${{ github.repository }}-scan
cancel-in-progress: false
jobs:
gate:
if: vars.AGENT_ENABLED != 'false'
runs-on: ${{ fromJson(vars.AGENT_RUNS_ON || '["ubuntu-latest"]') }}
outputs:
skip: ${{ steps.gate.outputs.skip }}
mode: ${{ steps.gate.outputs.mode }}
reason: ${{ steps.gate.outputs.reason }}
dependency_value: ${{ steps.gate.outputs.dependency_value }}
self_value: ${{ steps.gate.outputs.self_value }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
persist-credentials: false
ref: ${{ github.event.repository.default_branch }}
token: ${{ github.token }}
- name: Resolve scheduled activity gate
id: gate
uses: ./.github/actions/scheduled-activity-gate
with:
github_token: ${{ github.token }}
schedule_policy: ${{ vars.AGENT_SCHEDULE_POLICY || '' }}
workflow: agent-memory-scan.yml
dependency_ref: refs/agent-memory-state/sync
dependency_field: last_activity_at
self_ref: refs/agent-memory-state/scan
self_field: last_scan_at
scan:
needs: gate
if: vars.AGENT_ENABLED != 'false' && needs.gate.outputs.skip != 'true'
runs-on: ${{ fromJson(vars.AGENT_RUNS_ON || '["ubuntu-latest"]') }}
env:
MEMORY_REF: ${{ inputs.memory_ref || vars.AGENT_MEMORY_REF || 'agent/memory' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.repository.default_branch }}
token: ${{ github.token }}
- name: Resolve GitHub auth
id: auth
uses: ./.github/actions/resolve-github-auth
with:
app_id: ${{ secrets.AGENT_APP_ID }}
app_private_key: ${{ secrets.AGENT_APP_PRIVATE_KEY }}
pat: ${{ secrets.AGENT_PAT }}
fallback_token: ${{ github.token }}
- name: Resolve memory scan provider
id: provider
uses: ./.github/actions/resolve-agent-provider
with:
route: memory-scan
default_provider: ${{ vars.AGENT_DEFAULT_PROVIDER || 'auto' }}
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
claude_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
model_policy: ${{ vars.AGENT_MODEL_POLICY || '' }}
- name: Setup agent runtime
uses: ./.github/actions/setup-agent-runtime
with:
install_codex: ${{ steps.provider.outputs.install_codex }}
install_claude: ${{ steps.provider.outputs.install_claude }}
- name: Resolve task timeout
id: task_timeout
env:
AGENT_TASK_TIMEOUT_POLICY: ${{ vars.AGENT_TASK_TIMEOUT_POLICY || '' }}
ROUTE: answer
run: node .agent/dist/cli/resolve-task-timeout.js
- name: Curate memory from recent activity
id: scan
timeout-minutes: ${{ fromJson(steps.task_timeout.outputs.minutes || '30') }}
uses: ./.github/actions/run-agent-task
with:
agent: ${{ steps.provider.outputs.provider }}
github_token: ${{ steps.auth.outputs.token }}
secondary_github_token: ${{ secrets.AGENT_SECONDARY_GITHUB_TOKEN }}
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
claude_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
model: ${{ steps.provider.outputs.model }}
display_model: ${{ vars.AGENT_DISPLAY_MODEL || '' }}
permission_mode: approve-all
prompt: memory-scan
route: answer
memory_mode_override: 'enabled'
memory_ref: ${{ env.MEMORY_REF }}
memory_policy: ${{ vars.AGENT_MEMORY_POLICY || '' }}
session_policy: none
request_text: >-
Scheduled memory maintenance. Curate durable memory from recent repository activity; skip anything not worth carrying forward.
requested_by: ${{ github.actor }}
source_kind: workflow_dispatch
target_kind: repository
target_number: '0'
target_url: ${{ github.server_url }}/${{ github.repository }}
reasoning_effort: ${{ steps.provider.outputs.reasoning_effort || 'medium' }}
workflow: agent-memory-scan.yml
- name: Write memory scan state
if: steps.scan.outcome == 'success'
env:
GITHUB_REPOSITORY: ${{ github.repository }}
INPUT_GITHUB_TOKEN: ${{ steps.auth.outputs.token }}
REPO_SLUG: ${{ github.repository }}
SCHEDULE_LAST_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SCHEDULE_STATE_FIELD: last_scan_at
SCHEDULE_STATE_REF: refs/agent-memory-state/scan
run: node .agent/dist/cli/write-scheduled-state.js