mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-15 10:14:36 +00:00
fix(transformers): preserve tool ordering across proxy streams
- reject pending tool_result layouts that cannot be translated without reordering user content - keep interleaved GLMT tool_use blocks open until finalization instead of stopping early - cover leading/interleaved tool_result regressions and interleaved streaming tool fragments
This commit is contained in:
1 parent
889d3d89e9
commit
399f403322
5 files changed
+202
-34
No files matched your search
@@ -120,8 +120,48 @@ describe('ProxyRequestTransformer regressions', () => {
|
||||
},
|
||||
],
|
||||
})
|
||||
).toThrow('text is not allowed before tool_result blocks for pending tool_use ids');
|
||||
|
||||
expect(() =>
|
||||
new ProxyRequestTransformer().transform({
|
||||
messages: [
|
||||
{
|
||||
role: 'assistant',
|
||||
content: [{ type: 'tool_use', id: 'toolu_1', name: 'vision', input: { detail: 'high' } }],
|
||||
},
|
||||
{
|
||||
role: 'user',
|
||||
content: [
|
||||
{ type: 'tool_result', tool_use_id: 'toolu_1', content: 'result' },
|
||||
{ type: 'text', text: 'follow-up' },
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
).not.toThrow();
|
||||
|
||||
expect(() =>
|
||||
new ProxyRequestTransformer().transform({
|
||||
messages: [
|
||||
{
|
||||
role: 'assistant',
|
||||
content: [
|
||||
{ type: 'tool_use', id: 'toolu_1', name: 'search', input: { q: 'docs' } },
|
||||
{ type: 'tool_use', id: 'toolu_2', name: 'open', input: { url: 'https://example.com' } },
|
||||
],
|
||||
},
|
||||
{
|
||||
role: 'user',
|
||||
content: [
|
||||
{ type: 'tool_result', tool_use_id: 'toolu_1', content: 'partial' },
|
||||
{ type: 'text', text: 'follow-up' },
|
||||
{ type: 'tool_result', tool_use_id: 'toolu_2', content: 'done' },
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
).toThrow('text is not allowed between tool_result blocks for pending tool_use ids');
|
||||
|
||||
expect(() =>
|
||||
new ProxyRequestTransformer().transform({
|
||||
messages: [
|
||||
|
||||
Reference in new issue
Block a user