1
1
---
2
- title : " Agent Run Logs API "
3
- sidebarTitle : " Agent Run Logs "
2
+ title : " Retrieving Traces "
3
+ sidebarTitle : " Retrieving Traces "
4
4
icon : " list"
5
5
iconType : " solid"
6
6
---
7
7
8
- <Warning >
9
- This endpoint is currently in ** ALPHA** status and is subject to change. We welcome your feedback to help improve this API.
10
- </Warning >
11
-
12
8
The Agent Run Logs API allows you to retrieve detailed execution logs for agent runs, providing insights into the agent's thought process, tool usage, and execution flow.
13
9
14
10
## Endpoint
@@ -27,12 +23,12 @@ Authorization: Bearer YOUR_API_TOKEN
27
23
28
24
## Parameters
29
25
30
- | Parameter | Type | Required | Description |
31
- | -----------| ------| ---------- | -------------|
32
- | ` org_id ` | integer | Yes | Your organization ID |
33
- | ` agent_run_id ` | integer | Yes | The ID of the agent run to retrieve logs for |
34
- | ` skip ` | integer | No | Number of logs to skip for pagination (default: 0) |
35
- | ` limit ` | integer | No | Maximum number of logs to return (default: 100, max: 100) |
26
+ | Parameter | Type | Required | Description |
27
+ | -------------- | ------- | -------- | -- ------------------------------------------------------- |
28
+ | ` org_id ` | integer | Yes | Your organization ID |
29
+ | ` agent_run_id ` | integer | Yes | The ID of the agent run to retrieve logs for |
30
+ | ` skip ` | integer | No | Number of logs to skip for pagination (default: 0) |
31
+ | ` limit ` | integer | No | Maximum number of logs to return (default: 100, max: 100) |
36
32
37
33
## Response Structure
38
34
@@ -80,25 +76,25 @@ Each log entry in the `logs` array contains the following fields:
80
76
81
77
### Core Fields
82
78
83
- | Field | Type | Description |
84
- | -------| ------| -------------|
85
- | ` agent_run_id ` | integer | The ID of the agent run this log belongs to |
86
- | ` created_at ` | string | ISO 8601 timestamp when the log entry was created |
87
- | ` message_type ` | string | The type of log entry (see [ Log Types] ( #log-types ) below) |
79
+ | Field | Type | Description |
80
+ | -------------- | ------- | --------------------------------------------------------- |
81
+ | ` agent_run_id ` | integer | The ID of the agent run this log belongs to |
82
+ | ` created_at ` | string | ISO 8601 timestamp when the log entry was created |
83
+ | ` message_type ` | string | The type of log entry (see [ Log Types] ( #log-types ) below) |
88
84
89
85
### Agent Reasoning Fields
90
86
91
- | Field | Type | Description |
92
- | -------| ------| -------------|
87
+ | Field | Type | Description |
88
+ | --------- | -------------- | --------------------------------------------------------------- |
93
89
| ` thought ` | string \| null | The agent's internal reasoning or thought process for this step |
94
90
95
91
### Tool Execution Fields
96
92
97
- | Field | Type | Description |
98
- | -------| ------| -------------|
99
- | ` tool_name ` | string \| null | Name of the tool being executed (e.g., "ripgrep_search", "file_write") |
100
- | ` tool_input ` | object \| null | JSON object containing the parameters passed to the tool |
101
- | ` tool_output ` | object \| null | JSON object containing the tool's execution results |
93
+ | Field | Type | Description |
94
+ | ------------- | ------------------------ | ------------------------------------------------------------------------------ |
95
+ | ` tool_name ` | string \| null | Name of the tool being executed (e.g., "ripgrep_search", "file_write") |
96
+ | ` tool_input ` | object \| null | JSON object containing the parameters passed to the tool |
97
+ | ` tool_output ` | object \| null | JSON object containing the tool's execution results |
102
98
| ` observation ` | object \| string \| null | The agent's observation of the tool execution results or other contextual data |
103
99
104
100
## Log Types
@@ -107,58 +103,62 @@ The `message_type` field indicates the type of log entry. Here are the possible
107
103
108
104
### Plan Agent Types
109
105
110
- | Type | Description |
111
- | ------| -------------|
112
- | ` ACTION ` | The agent is executing a tool or taking an action |
113
- | ` PLAN_EVALUATION ` | The agent is evaluating or updating its plan |
114
- | ` FINAL_ANSWER ` | The agent is providing its final response or conclusion |
115
- | ` ERROR ` | An error occurred during execution |
116
- | ` USER_MESSAGE ` | A message from the user (e.g., interruptions or additional context) |
117
- | ` USER_GITHUB_ISSUE_COMMENT ` | A comment from a GitHub issue that the agent is processing |
106
+ | Type | Description |
107
+ | --------------------------- | ------------------------------------------------------------------- |
108
+ | ` ACTION ` | The agent is executing a tool or taking an action |
109
+ | ` PLAN_EVALUATION ` | The agent is evaluating or updating its plan |
110
+ | ` FINAL_ANSWER ` | The agent is providing its final response or conclusion |
111
+ | ` ERROR ` | An error occurred during execution |
112
+ | ` USER_MESSAGE ` | A message from the user (e.g., interruptions or additional context) |
113
+ | ` USER_GITHUB_ISSUE_COMMENT ` | A comment from a GitHub issue that the agent is processing |
118
114
119
115
### PR Agent Types
120
116
121
- | Type | Description |
122
- | ------| -------------|
123
- | ` INITIAL_PR_GENERATION ` | The agent is generating the initial pull request |
124
- | ` DETECT_PR_ERRORS ` | The agent is detecting errors in a pull request |
125
- | ` FIX_PR_ERRORS ` | The agent is fixing errors found in a pull request |
126
- | ` PR_CREATION_FAILED ` | Pull request creation failed |
127
- | ` PR_EVALUATION ` | The agent is evaluating a pull request |
117
+ | Type | Description |
118
+ | ----------------------- | -------------------------------------------------- |
119
+ | ` INITIAL_PR_GENERATION ` | The agent is generating the initial pull request |
120
+ | ` DETECT_PR_ERRORS ` | The agent is detecting errors in a pull request |
121
+ | ` FIX_PR_ERRORS ` | The agent is fixing errors found in a pull request |
122
+ | ` PR_CREATION_FAILED ` | Pull request creation failed |
123
+ | ` PR_EVALUATION ` | The agent is evaluating a pull request |
128
124
129
125
### Commit Agent Types
130
126
131
- | Type | Description |
132
- | ------| -------------|
127
+ | Type | Description |
128
+ | ------------------- | ------------------------------- |
133
129
| ` COMMIT_EVALUATION ` | The agent is evaluating commits |
134
130
135
131
### Link Types
136
132
137
- | Type | Description |
138
- | ------| -------------|
133
+ | Type | Description |
134
+ | ---------------- | ----------------------------------- |
139
135
| ` AGENT_RUN_LINK ` | A link to another related agent run |
140
136
141
137
## Field Population Patterns
142
138
143
139
Different log types populate different fields:
144
140
145
141
### ACTION Logs
142
+
146
143
- Always have: ` tool_name ` , ` tool_input ` , ` tool_output `
147
144
- Often have: ` thought ` , ` observation `
148
145
- Example: Tool executions like searching code, editing files, creating PRs
149
146
150
147
### PLAN_EVALUATION Logs
148
+
151
149
- Always have: ` thought `
152
150
- May have: ` observation `
153
151
- Rarely have: Tool-related fields
154
152
- Example: Agent reasoning about next steps
155
153
156
154
### ERROR Logs
155
+
157
156
- Always have: ` observation ` (containing error details)
158
157
- May have: ` tool_name ` (if error occurred during tool execution)
159
158
- Example: Failed tool executions or system errors
160
159
161
160
### FINAL_ANSWER Logs
161
+
162
162
- Always have: ` observation ` (containing the final response)
163
163
- May have: ` thought `
164
164
- Example: Agent's final response to the user
@@ -208,12 +208,12 @@ while True:
208
208
url = f " https://api.codegen.com/v1/organizations/67890/agent/run/12345/logs?skip= { skip} &limit= { limit} "
209
209
response = requests.get(url, headers = headers)
210
210
data = response.json()
211
-
211
+
212
212
all_logs.extend(data[' logs' ])
213
-
213
+
214
214
if len (data[' logs' ]) < limit:
215
215
break # No more logs
216
-
216
+
217
217
skip += limit
218
218
219
219
print (f " Retrieved { len (all_logs)} total logs " )
@@ -234,26 +234,34 @@ for error_log in error_logs:
234
234
## Common Use Cases
235
235
236
236
### 1. Building Monitoring Dashboards
237
+
237
238
Use the logs to create dashboards showing:
239
+
238
240
- Agent execution progress
239
241
- Tool usage patterns
240
242
- Error rates and types
241
243
- Execution timelines
242
244
243
245
### 2. Debugging Agent Behavior
246
+
244
247
Analyze logs to understand:
248
+
245
249
- Why an agent made certain decisions
246
250
- Where errors occurred in the execution flow
247
251
- What tools were used and their results
248
252
249
253
### 3. Audit and Compliance
254
+
250
255
Track agent actions for:
256
+
251
257
- Code change auditing
252
258
- Compliance reporting
253
259
- Security monitoring
254
260
255
261
### 4. Performance Analysis
262
+
256
263
Monitor:
264
+
257
265
- Tool execution times
258
266
- Common failure patterns
259
267
- Agent reasoning efficiency
@@ -265,13 +273,13 @@ Monitor:
265
273
266
274
## Error Responses
267
275
268
- | Status Code | Description |
269
- | ------------- | -------------|
270
- | 400 | Bad Request - Invalid parameters |
271
- | 401 | Unauthorized - Invalid or missing API token |
272
- | 403 | Forbidden - Insufficient permissions |
273
- | 404 | Not Found - Agent run not found |
274
- | 429 | Too Many Requests - Rate limit exceeded |
276
+ | Status Code | Description |
277
+ | ----------- | -- ----------------------------------------- |
278
+ | 400 | Bad Request - Invalid parameters |
279
+ | 401 | Unauthorized - Invalid or missing API token |
280
+ | 403 | Forbidden - Insufficient permissions |
281
+ | 404 | Not Found - Agent run not found |
282
+ | 429 | Too Many Requests - Rate limit exceeded |
275
283
276
284
## Feedback and Support
277
285
@@ -282,6 +290,6 @@ Since this endpoint is in ALPHA, we'd love your feedback! Please reach out throu
282
290
283
291
284
292
<Note >
285
- The structure and fields of this API may change as we gather feedback and improve the service. We'll provide advance notice of any breaking changes.
293
+ The structure and fields of this API may change as we gather feedback and
294
+ improve the service. We'll provide advance notice of any breaking changes.
286
295
</Note >
287
-
0 commit comments