Skip to content

feat(agent-connector): fully integrate Gemini CLI and fix stream JSON parsing bugs#357

Merged
nebukaga merged 2 commits into
openagents-org:developfrom
zhoumzh:feature/gemini-integration
May 4, 2026
Merged

feat(agent-connector): fully integrate Gemini CLI and fix stream JSON parsing bugs#357
nebukaga merged 2 commits into
openagents-org:developfrom
zhoumzh:feature/gemini-integration

Conversation

@zhoumzh
Copy link
Copy Markdown
Contributor

@zhoumzh zhoumzh commented Apr 23, 2026

Description

This PR fully integrates the Gemini CLI into the OpenAgents ecosystem and resolves several critical issues that previously prevented the Gemini adapter from working correctly in the Desktop Launcher.

🐛 Bug Fixes

  • JSON Stream Parsing: Fixed a critical bug in GeminiAdapter where split('\\n') was mistakenly used instead of split('\n'). This prevented the CLI's stream-json output from being parsed correctly, resolving the silent No response generated errors.

✨ Features & Improvements

  • Native Authentication Flow: Removed the mandatory GEMINI_API_KEY UI input requirement in registry.json and added login_command: "gemini login". This aligns Gemini with Claude's elegant CLI OAuth flow.
  • Aggressive Polling for Lower Latency: Reduced the maximum idle adaptive polling delay in BaseAdapter._pollLoop() from 15 seconds to 3 seconds. This significantly improves responsiveness when chatting with local agents from the remote Workspace.
  • Enhanced Debuggability: Added full stack trace (e.stack) logging for joinNetwork failures to make troubleshooting ECONNREFUSED and 404 errors easier.

🛠 Development Environment

  • Local Source Prioritization: Modified AgentManager.loadCore() to prioritize loading the local workspace agent-connector code instead of the globally installed @openagents-org/agent-launcher. This makes local development and hot-reloading functional.
  • Headless & GPU Options: Added --disable-gpu and --headless startup flags in package.json and main.js to mitigate severe UI lag during local Electron testing.

Documentation

Included a detailed changelog and a technical blog post documenting the debugging journey and infrastructure fixes in changelogs/notes/gemini_integration_fix.md and changelogs/blogs/2026-04-23-gemini_integration_journey.md.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

Someone is attempting to deploy a commit to the Raphael's projects Team on Vercel.

A member of the Team first needs to authorize it.

@nebukaga nebukaga merged commit 8d79ed0 into openagents-org:develop May 4, 2026
11 of 19 checks passed
nebukaga added a commit that referenced this pull request May 4, 2026
PR #357 silently included a poll-rate change from 2s active / up to 15s
idle to 1s/3s in base.js. That's orthogonal to the Gemini integration
that was the PR's stated subject and meaningfully increases load — every
connected agent runs this loop, so a 5× increase in idle rate multiplies
across every workspace member. We just spent considerable effort tuning
the head-cursor cache + Postgres pool for the existing rate; raising it
should be its own change with a measured load-impact analysis on
workspace-endpoint.
@zomux
Copy link
Copy Markdown
Contributor

zomux commented May 4, 2026

Landed on develop in 8d79ed0 (authored as you), with one follow-up immediately after in 9f5b3f7 that reverts just the polling-rate change in base.js (2s/15s → 1s/3s). The polling change is orthogonal to Gemini integration and warrants its own PR with a load-impact analysis — every connected agent runs that loop, so faster rates multiply across the whole workspace, and we recently tuned the head-cursor cache + Postgres pool for the existing rate.

Conflict resolution note: this PR was branched before e358b64 ("Fix per-agent model config in launcher"), so its agent-manager.js changes would have reverted the per-instance env-var feature. Took develop's version of agent-manager.js entirely; the local agent-connector source priority in loadCore() is already on develop via PR #359 with equivalent logic.

Two small follow-ups worth knowing about:

  1. gemini.js:248cleanEnv = { ...(this.agentEnv || process.env) } doesn't actually clean. We just merged a fix in claude.js (d9f5449) that strips CLAUDE_* / ANTHROPIC_API_KEY / AI_AGENT_* before spawning the subprocess. Same scrub probably belongs here so a Gemini agent doesn't see Anthropic creds in its env.
  2. There's a leftover dev-thinking comment block around line 365 of gemini.js ("Gemini deltas are partial strings, no newline needed... but wait...") — fine, just noise.

Thanks for the bug fix on split('\n') — that's been masked behind the "No response generated" message for a while.

nebukaga added a commit that referenced this pull request May 4, 2026
The npm publish workflow has been failing on every push since 0.2.114
(2026-04-30) because the version in package.json wasn't bumped — so
the Stop button fix from PR #368, the Gemini integration from PR #357,
the workspace-removal API from PR #359, and the env-var scrub from
d9f5449 are all on develop but not in users' local launcher installs.

Test fix: stop-control.test.js was written against the old sendStatus
path, but 6cfc575 (post chat reply on shutdown) had already changed
_stopAllProcesses to call sendResponse instead. The two PRs auto-merged
without conflict, leaving the test asserting against the wrong mock.
Updated the test to mock sendResponse and pass the message explicitly.
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