Skip to content

Conversation

@pawbana
Copy link
Contributor

@pawbana pawbana commented Jan 15, 2026

No description provided.

Copy link
Contributor Author

pawbana commented Jan 15, 2026

@pawbana pawbana force-pushed the pb/responses-record-tool-usage branch 2 times, most recently from b0290a7 to ee80a4b Compare January 16, 2026 08:18
@pawbana pawbana marked this pull request as ready for review January 16, 2026 08:19
expected: nil,
},
{
name: "nested_object",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: _with_trailing_spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Comment on lines 204 to 205
recordedTools[0].InterceptionID = tc.expectToolRecorded.InterceptionID // ignore interception id
recordedTools[0].CreatedAt = tc.expectToolRecorded.CreatedAt // ignore time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively you can clear both fields if ignored

func (i *responsesInterceptionBase) parseJSONArgs(raw string) recorder.ToolArgs {
if trimmed := strings.TrimSpace(raw); trimmed != "" {
var args recorder.ToolArgs
if err := json.Unmarshal([]byte(trimmed), &args); err == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do something if JSON is borked?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed; errors should be handled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Logic was wrong here. Updated it to match what is done in chat completions.

ID: "resp_789",
Output: []oairesponses.ResponseOutputItemUnion{
{
Type: "function_call",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm... do we need another test for function_call with broken args?

}
}

func (i *responsesInterceptionBase) parseJSONArgs(raw string) recorder.ToolArgs {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method isn't well named. It should indicate that it's just for tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated name

func (i *responsesInterceptionBase) parseJSONArgs(raw string) recorder.ToolArgs {
if trimmed := strings.TrimSpace(raw); trimmed != "" {
var args recorder.ToolArgs
if err := json.Unmarshal([]byte(trimmed), &args); err == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed; errors should be handled.

// recodring other function types to be considered: https://github.com/coder/aibridge/issues/121
switch item.Type {
case "function_call":
args = i.parseJSONArgs(item.Arguments)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary to do? Why can't we pass the string value like we do for the others?
By the time it's stored in the db it's a string anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to keep it consistent with chat completions.

You are right this seems redundant with how we store things in DB but then recorder API should change (ToolUsageRecord should have Args as string instead of any)?

recordedTools := mockRecorder.RecordedToolUsages()
if tc.expectToolRecorded != nil {
require.Len(t, recordedTools, 1)
recordedTools[0].InterceptionID = tc.expectToolRecorded.InterceptionID // ignore interception id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a reason why.

@pawbana pawbana force-pushed the pb/responses-record-tool-usage branch from 8ecf6e4 to 7bdf03a Compare January 16, 2026 13:32
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good on my end!

@pawbana pawbana force-pushed the pb/responses-record-tool-usage branch from 7bdf03a to 11d3c46 Compare January 16, 2026 14:56
Copy link
Contributor Author

pawbana commented Jan 16, 2026

Merge activity

  • Jan 16, 2:58 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 16, 2:58 PM UTC: @pawbana merged this pull request with Graphite.

@pawbana pawbana merged commit 3a8e822 into main Jan 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants