fix(core): Fix for incorrect time.start reset in tool call logging (#32574) - #32596
Merged
Merged
Conversation
Contributor
Author
|
FYI: The GHA failures shown at:
don't seem to be related to the code changes I made. I added the new test:
The failing tests seem to be in:
and the final error looks like: Looks like we see the same errors in other GHA builds for other PRs like: showing the same error output: What is the chance that two different random PRs from different developers are triggering the same errors? Me thinks the test suite for opencode is broken on Detecting problems with the test suite seems like a good task for an AI agent! |
New test fails if you don't have this fix.
bartlettroscoe
force-pushed
the
23574-fix-time-start
branch
from
June 20, 2026 23:00
9432811 to
27f2743
Compare
Contributor
Author
|
@kitlangton, can you take a look as part of #32574? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
New test fails if you don't have this fix.
Issue for this PR
Closes #32574
Type of change
What does this PR do?
Fixes the "start" time in the "time" block for json tool calling output so it produces the right start time and time difference.
Before this fix, running:
produced a JSON dict like:
{ "type": "text", "timestamp": 1781623587086, "sessionID": "ses_12ef5b29dffeNWj9H9elnMCmbv", "part": { "id": "prt_ed10a7fc1001cnEl1E5FBGo5IC", "messageID": "msg_ed10a7ef7001MqJ2vUha3IZkzN", "sessionID": "ses_12ef5b29dffeNWj9H9elnMCmbv", "type": "text", "text": "The command produced the following output:\n\n```\nreal\t0m10.001s\nuser\t0m0.000s\nsys\t0m0.001s\n```", "time": { "start": 1781623586753, "end": 1781623587085 } } }where 1781623587085 - 1781623586753 = 332 ms, or 0.332 sec and is clearly not anywhere close to 10 seconds.
After the fix in this PR, the local build of of
opencodeproduces something like:{ "type": "text", "timestamp": 1781635217752, "sessionID": "ses_12e44bf64ffer14wSI0QfvgZtj", "part": { "id": "prt_ed1bbd3c9001Iv3RErkj2zz4dz", "messageID": "msg_ed1bbc128001JABc8U374fps3W", "sessionID": "ses_12e44bf64ffer14wSI0QfvgZtj", "type": "text", "text": "The command took approximately 10 seconds to complete:\n\n```\nreal\t0m10.001s\nuser\t0m0.000s\nsys\t0m0.001s\n```\n\n- **real**: Total elapsed time (10.001s)\n- **user**: CPU time in user mode (negligible)\n- **sys**: CPU time in kernel mode (negligible)", "time": { "start": 1781635208137, "end": 1781635217750 } } }where 1781635217750 - 1781635208137 = 9613 ms = 9.613 sec is close enough to 10.0 sec.
How did you verify your code works?
I added a new unit test in this PR that fails without the patch and passed with the patch.
I also built and run the binary locally with:
and verified that it gave a reasonable timing for a command that should take 10 sec. The above produced:
{ "type": "text", "timestamp": 1781635217752, "sessionID": "ses_12e44bf64ffer14wSI0QfvgZtj", "part": { "id": "prt_ed1bbd3c9001Iv3RErkj2zz4dz", "messageID": "msg_ed1bbc128001JABc8U374fps3W", "sessionID": "ses_12e44bf64ffer14wSI0QfvgZtj", "type": "text", "text": "The command took approximately 10 seconds to complete:\n\n```\nreal\t0m10.001s\nuser\t0m0.000s\nsys\t0m0.001s\n```\n\n- **real**: Total elapsed time (10.001s)\n- **user**: CPU time in user mode (negligible)\n- **sys**: CPU time in kernel mode (negligible)", "time": { "start": 1781635208137, "end": 1781635217750 } } }where 1781635217750 - 1781635208137 = 9613 ms = 9.613 sec is close enough to 10.0 sec.
Screenshots / recordings
I don't have any screenshots. They are not needed. The above is enough to fully expose the defect and demonstrate the fix.
If this is a UI change, please include a screenshot or recording.
Checklist
If you do not follow this template your PR will be automatically rejected.