r/PiCodingAgent • u/adamshand • 4d ago
Question Using Gemini Neon with a subscription?
Anyone have Hydrogen/Neon working on subscription pricing with Pi?
Just got a Copilot sub to test it out and really like Neon, but Copilot is giving sporadic errors with Gemini models:
Error: Stream ended without finish_reason
As far as I can tell it's nothing to do with my setup. Disabled all extension etc and still getting an error.
7
Upvotes
6
u/Drugba 4d ago
I was using the pi-antigravity extension for about a week and just got my account suspended a few hours ago. Even before then though the set up was kind of janky and I regularly got weird errors like the one you’re seeing.
As far as I can tell, there’s no long term way to use it outside of antigravity other than paying for the API.
Open Code Go subscription has Argon as an option so maybe they’ll get the other models sometimes soon. That’s really my only hope.
2
u/Dangerous-Relation-5 2d ago
Logan from Google said Dec 2nd they have something.
I the meantime I made an extension that uses that antigravity acp https://github.com/bskimball/pi/tree/main/agent/extensions/antigravity-native
Try it out. You obviously have to have the antigravity cli installed.
1
u/Slow-Secretary4262 4d ago
someone from google on twitter said something about third party harnesses is scheduled for december 2, i dont have high hopes but we'll see
1
u/Delvan_Zahraei 4d ago
Does it still throw that if you turn off streaming responses in the settings? Sometimes the wrapper just fails to parse the final SSE chunk properly from certain model families
1
u/Affectionate_Fee232 3d ago
Hey i was having same issue in pi with copilot - this fixed it:
import { randomUUID } from 'node:crypto';
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
const provider = 'github-copilot';
const api = 'openai-completions';
const model = 'gemini-4-neon';
const signatureKind = 'local/copilot-neon-replay/v1';
type Replay = { reasoning_opaque: string; reasoning_text?: string };
function record(value: unknown): value is Record<string, unknown> {
return value !== null && typeof value === 'object' && !Array.isArray(value);
}
function isNeon(m?: { provider: string; api: string; id: string; baseUrl: string }) {
return m?.provider === provider && m.api === api && m.id === model &&
/^https:\/\/api\.(?:(?:individual|business|enterprise)\.)?githubcopilot\.com\/?$/.test(m.baseUrl);
}
function unpack(signature?: string): Replay | undefined {
if (!signature?.startsWith('{')) return;
try {
const value: unknown = JSON.parse(signature);
if (record(value) && value.kind === signatureKind && typeof value.reasoning_opaque === 'string' && value.reasoning_opaque) {
return { reasoning_opaque: value.reasoning_opaque, ...(typeof value.reasoning_text === 'string' && { reasoning_text: value.reasoning_text }) };
}
} catch { /* A different adapter may use a non-JSON signature. */ }
}
export default function neonCopilotReplay(pi: ExtensionAPI) {
let partial: { id: string; opaque?: string; text: string } | undefined;
// Per-extension, per-context references. Only the final, verified Neon payload gets the token.
const format = `local-neon-${randomUUID()}`;
const references = new Map<string, Replay>();
pi.on('provider_stream_event', (event, ctx) => {
if (event.provider !== provider || event.api !== api || event.model !== model || !isNeon(ctx.model)) return;
const chunk = event.data;
if (!record(chunk) || typeof chunk.id !== 'string' || !chunk.id || !Array.isArray(chunk.choices)) return;
const delta: unknown = chunk.choices[0]?.delta;
if (!record(delta)) return;
if (partial?.id !== chunk.id) partial = { id: chunk.id, text: '' };
if (typeof delta.reasoning_text === 'string') partial.text += delta.reasoning_text;
if (typeof delta.reasoning_opaque === 'string' && delta.reasoning_opaque) partial.opaque = delta.reasoning_opaque;
});
pi.on('message_end', ({ message }, ctx) => {
if (message.role !== 'assistant') return;
const captured = partial;
partial = undefined;
if (!captured?.opaque || !isNeon(ctx.model) || message.provider !== provider || message.api !== api ||
message.model !== model || message.responseId !== captured.id || !['stop', 'toolUse'].includes(message.stopReason)) return;
// Do not override native structured reasoning if Pi or the provider starts supplying it.
if (message.content.some(b => (b.type === 'toolCall' && b.thoughtSignature) ||
(b.type === 'thinking' && b.thinkingSignature && !['reasoning_text', 'reasoning', 'reasoning_content'].includes(b.thinkingSignature)))) return;
const thinkingSignature = JSON.stringify({ kind: signatureKind, reasoning_opaque: captured.opaque,
...(captured.text && { reasoning_text: captured.text }) });
const content = [...message.content];
const i = content.findIndex(b => b.type === 'thinking');
const block = content[i];
if (block?.type === 'thinking') content[i] = { ...block, thinkingSignature };
else content.unshift({ type: 'thinking', thinking: '', thinkingSignature });
return { message: { ...message, content } };
});
pi.on('context_with_system', ({ messages }, ctx) => {
references.clear();
if (!isNeon(ctx.model)) return;
// The wire format loses Pi's response IDs. Carry a request-local reference through
// Pi's supported reasoning_details conversion rather than matching text or tool IDs.
const next = messages.map(msg => {
if (msg.role !== 'assistant' || msg.provider !== provider || msg.api !== api || msg.model !== model) return msg;
const content = msg.content.map(block => {
if (block.type !== 'thinking') return block;
const replay = unpack(block.thinkingSignature);
if (!replay) return block;
const ref = randomUUID();
references.set(ref, replay);
return { ...block, thinkingSignature: JSON.stringify([{ type: 'reasoning.encrypted', format, data: ref }]) };
});
return { ...msg, content };
});
if (references.size) return { messages: next };
});
pi.on('before_provider_request', ({ payload }, ctx) => {
partial = undefined;
if (!references.size || !record(payload) || !Array.isArray(payload.messages)) return;
const target = isNeon(ctx.model) && payload.model === model;
let changed = false;
const messages = payload.messages.map((msg: unknown) => {
if (!record(msg) || msg.role !== 'assistant' || !Array.isArray(msg.reasoning_details) || msg.reasoning_details.length !== 1) return msg;
const detail: unknown = msg.reasoning_details[0];
if (!record(detail) || detail.format !== format || typeof detail.data !== 'string') return msg;
const { reasoning_details: _, ...rest } = msg;
changed = true;
const replay = target ? references.get(detail.data) : undefined;
return replay && rest.reasoning_opaque === undefined ? { ...rest, ...replay } : rest;
});
if (changed) return { ...payload, messages };
});
pi.on('session_shutdown', () => { partial = undefined; references.clear(); });
}
1
u/Fabulous-Ladder3267 4d ago
Dont use antigravity subs outside google product (antrigravity cli, desktop, ide, ai stufio, etc).
Your account will be banned immediately or after 1 day use (like on 9router/omniroute) if using newer model (4 series)
0
u/schmurfy2 4d ago
Maybe tru opencode Go.
-1
u/Asleep-Land-3914 4d ago
Don't you have an AI to sort it out?