Skip to content

Conversation

@zikajk
Copy link
Member

@zikajk zikajk commented Jan 12, 2026

  • Normalizes ECA’s interleaved tool history into OpenAI/Gemini-compatible turns: all parallel tool_calls first, then all tool outputs, without merging sequential tool-loop rounds (uses :tool-turn-id boundaries).

  • Preserves Gemini extra_content.google.thought_signature across turns (stored as :external-id and emitted back on tool_calls), preventing 400 INVALID_ARGUMENT on Gemini 3 Flash tool calls.

  • Makes streamed tool execution deterministic even when providers omit tool_calls[].index (fallback :stream-order) and avoids tool-loop stalls on invalid JSON tool arguments.

  • Adds unit tests covering ordering, tool-turn boundaries, thought_signature preservation, and deterministic execution.

  • I added a entry in changelog under unreleased section.

@zikajk zikajk requested a review from ericdallo January 12, 2026 07:44
- Normalizes ECA’s interleaved tool history into OpenAI/Gemini-compatible turns: all parallel tool_calls first, then all tool outputs, without merging sequential tool-loop rounds (uses :tool-turn-id boundaries).
- Preserves Gemini extra_content.google.thought_signature across turns (stored as :external-id and emitted back on tool_calls), preventing 400 INVALID_ARGUMENT on Gemini 3 Flash tool calls.
- Makes streamed tool execution deterministic even when providers omit tool_calls[].index (fallback :stream-order) and avoids tool-loop stalls on invalid JSON tool arguments.
- Adds unit tests covering ordering, tool-turn boundaries, thought_signature preservation, and deterministic execution.
@zikajk zikajk force-pushed the fix-gemini-openai-chat-tool-calling branch from 4f97ff0 to ad33856 Compare January 12, 2026 07:54
Copy link
Member

@ericdallo ericdallo left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

@ericdallo ericdallo merged commit d156674 into master Jan 12, 2026
7 checks passed
@stsquad
Copy link

stsquad commented Jan 12, 2026

Hmm /init still fails:

[server] Starting server...
[DB] No existing DB cache found for /home/alex/.cache/eca/db.transit.json
:db/read-cache 0ms
:db/read-cache 14ms
:eca/initialize 15ms
[LLM-API] Default LLM model 'anthropic/claude-sonnet-4.5' decision ':default'
[LLM-API] Default LLM model 'anthropic/claude-sonnet-4.5' decision ':default'
:eca/initialized 280ms
:eca/chat-query-commands 0ms
:eca/chat-prompt 15ms
:db/upsert-cache 1ms
[TOOLS] Calling tool 'eca__directory_tree' with args '{"path" "/home/alex/mysrc/hubi.git", "max_depth" 2}'
[OPENAI-CHAT] 3949 Unexpected response status: %s body: %s 400 [{
  "error": {
    "code": 400,
    "message": "Please ensure that function call turn comes immediately after a user turn or after a function response turn.",
    "status": "INVALID_ARGUMENT"
  }
}
]
{:message LLM response status: 400 body: [{
  "error": {
    "code": 400,
    "message": "Please ensure that function call turn comes immediately after a user turn or after a function response turn.",
    "status": "INVALID_ARGUMENT"
  }
}
]}
:db/upsert-cache 0ms
:db/upsert-cache 0ms

with:

/init
Rollback chat to before this message

Thought 0.00 s
**Formulating the Plan**

I'm currently focused on the structure of the `AGENTS.md` file. I'll need to define sections for build, lint, and test commands, especially a single test run. Code style guidelines are also a priority. I'm exploring the codebase to understand the build process.




Listing file tree ✅ 0.02 s

Tool: directory_tree
Server: eca
Arguments: 
  path: "/home/alex/mysrc/hubi.git"
  max_depth: 2

Output: /home/alex/mysrc/hubi.git
 Makefile
 README.org
 TODO.org
 docs
  screenshot.png
 hubi-configure.el
 hubi-ert.el
 hubi.el

1 directories, 7 files


LLM response status: 400 body: [{
  "error": {
    "code": 400,
    "message": "Please ensure that function call turn comes immediately after a user turn or after a function response turn.",
    "status": "INVALID_ARGUMENT"
  }
}
]

it looks like its the latest binary:

➜  ps ax | grep eca
2526115 ?        Ssl    0:00 /home/alex/.emacs.d/eca/eca server
2528005 pts/9    S+     0:00 grep --color=auto eca
🕙13:41:22 alex@draig:qemu.git/builds/all  on  cpus/cleanup-cpu-reset [$!?] 
➜  /home/alex/.emacs.d/eca/eca --version
eca 0.90.1
🕙13:41:28 alex@draig:qemu.git

@zikajk
Copy link
Member Author

zikajk commented Jan 12, 2026

image

@ericdallo
Copy link
Member

@zikajk does /init works for you?

@zikajk
Copy link
Member Author

zikajk commented Jan 12, 2026

@ericdallo It doesn't :-(. Interesting...

@zikajk
Copy link
Member Author

zikajk commented Jan 12, 2026

I will try to take a look soon why is that.

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.

4 participants