Commit Graph
10 Commits
Author SHA1 Message Date
can1357 e1d2dfeffa fix(ai): parse first streaming tool args
Addresses review feedback on #1507.
2026-05-31 04:49:20 +02:00
oldschoolaandcan1357 3a733c480b perf(agent,ai,coding-agent): in-place state mutation + per-delta json-parse throttle + drop hot-path structuredClone
F3 (agent): mutate state.messages and state.pendingToolCalls in place on
appendMessage/popMessage/clearMessages/reset/tool_execution_start/_end
instead of allocating a fresh array/Set on every transition. Subscribers
that capture state.messages by reference now observe updates directly.
Public type signature unchanged.

F5 (ai): add parseStreamingJsonThrottled to utils/json-parse — a per-delta
wrapper around parseStreamingJson that skips the re-parse until the
buffer has grown by minGrowthBytes (default 256). Wired into every
provider's tool-call argument accumulator (anthropic, amazon-bedrock,
openai-completions, openai-codex-responses, openai-responses-shared) so
per-delta cost becomes O(N) in total buffer length instead of O(N²).
Every provider's toolcall_end still runs a final unthrottled parse, so
the published block.arguments is unchanged.

F8 (coding-agent): drop the per-delta structuredClone of streaming tool
arguments in ToolExecutionComponent.updateArgs. event-controller.ts and
ui-helpers.ts already spread their input into a fresh object on each
delta, so cloning here was dead work on the rendering hot path. Added a
reference-equality short-circuit so repeat calls with the same args
object skip the preview-diff and display refresh.
2026-05-31 04:46:06 +02:00
can1357 ef95756354 refactor(ai): simplified streaming JSON parsing and removed unused user agent helper
- Removed the unused `antigravity-user-agent.ts` file from the AI providers.
- Updated `parseStreamingJson` to trim only leading whitespace, try `JSON.parse` first, then partial parsing on repaired input before returning an empty object on failure.
- Removed a streaming JSON test that depended on preserving trailing spaces in incomplete string fragments.
2026-05-02 06:59:25 +02:00
can1357 ac1bacbeab fix(ai/utils): reworked JSON repair to efficiently fix malformed string escapes
- Optimized `repairJson` to scan JSON input incrementally and only patch invalid escape sequences or raw control characters.
- Reworked escape validation with byte-level constants and stricter `\uXXXX` handling for truncated or non-hex sequences.
- Added coverage for valid escapes, control-character repair, literal invalid-escape preservation, and whitespace-only streaming JSON inputs.
2026-05-02 02:03:15 +02:00
can1357 e22e75e70e feat(ai): added Anthropic raw SSE decoding with malformed payload repair
- Added a runtime export for `OpenAICodexResponsesOptions` and `AnthropicCompat` capability flags.
- Added Anthropic raw SSE decoding, envelope filtering, repaired JSON parsing, and thinking/eager-input support.
- Added `repairJson`/`parseJsonWithRepair` and OAuth `postJson()` with `formatErrorDetails()` for richer stream/auth failures.
- Changed OpenAI Codex streaming to default verbosity to `low`, send `previous_response_id` on continuations, and record websocket debug stats.
- Added raw SSE and websocket tests for unknown trace events, malformed payload repair, continuation IDs, and debug counters.
2026-05-02 00:54:08 +02:00
can1357 60e255f167 feat(ai): enabled literal null string preservation in JSON parsing
- Removed `coerceNullStrings` function and automatic null-string coercion from JSON parsing, changing behavior to preserve literal `"null"` strings.
- Updated `parseStreamingJson` to return parsed JSON without null-string transformation.
2026-04-06 18:46:07 +02:00
can1357 791296669f fix(ai): coerce "null" strings in streamed JSON tool args 2026-04-06 18:40:40 +02:00
can1357 5a63120dd3 feat(ai): add @oh-my-pi/pi-ai package with tool name prefixing
- Port pi-ai from upstream with Bun-first approach (source files, no dist)
- Add cli_ prefix to tool names in OAuth mode to avoid collisions
- Improve beta header handling with proper deduplication
- Convert codex-instructions.md to Bun text embed
- Strip .js extensions from all imports
2026-01-09 12:10:03 +01:00
can1357 5919b0df94 refactor: switched to upstream @mariozechner/pi-ai and removed unused packages
- Replaced local @oh-my-pi/pi-ai with upstream @mariozechner/pi-ai@0.37.4
- Added sessionId support to agent for provider caching (OpenAI Codex)
- Deleted packages/ai (now using upstream)
- Deleted packages/mom (unused)
- Deleted packages/web-ui (unused)
2026-01-06 22:25:24 +00:00
Mario Zechner 2296dc4052 refactor(ai): improve error handling and stop reason types
- Add 'aborted' as a distinct stop reason separate from 'error'
- Change AssistantMessage.error to errorMessage for clarity
- Update error event to include reason field ('error' | 'aborted')
- Map provider-specific safety/refusal reasons to 'error' stop reason
- Reorganize utility functions into utils/ directory
- Rename agent.ts to agent-loop.ts for better clarity
- Fix error handling in all providers to properly distinguish abort from error
2025-09-18 19:57:13 +02:00