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.
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/adamshand 1d ago
Nice, will have a look! But with the extension from Affectionate_Fee232, copilot is actually working great and I get all models natively in Pi which is great.
1
1
u/Slow-Secretary4262 3d 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
1
u/m3umax 3d ago
So I should speculatively grab the Black Friday half price Google AI deal then? 🤣
1
u/Slow-Secretary4262 3d ago
i wouldn't trust them, remember a year ago or so they were hyping old terrible gemini models like crazy before release, so i don't trust google employees twitter yap anymore, but copium is still high
1
u/Delvan_Zahraei 3d 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/adamshand 3d ago
Good thought, thanks!
It’s sporadic and seems to be query specific, especially on queries that do tool usage.
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
1
u/adamshand 1d ago
For anyone else that comes across this bug, the above fix resolves it and I've reported the bug upstream.
1
u/Affectionate_Fee232 3d ago
also gemini models in copilot have image issues like only 10 images allowed and they have to be smaller size - workaround i did was tell astra to create an extension when gemini model is on - to compress the images and remove/rotate images from the context after 8 pictures - if you send images you will run into this i promise lol
1
u/adamshand 2d ago
Perfect, thanks for the tip. I just figured out that compacting seems to fix the problem and allow things to carry on as well.
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)
1
u/auggie246 4d ago
Even with pi acp? T3 code uses antigravity acp.
2
u/RainScum6677 3d ago
For t3 seems to be just fine with acp. Also, google marked December 2nd as the date where they, in some form, will start supporting third party usage of their sub.
1
1
u/Fabulous-Ladder3267 4d ago
Never try through acp yet, might be fine because it still use Antrigravity.
0
-1
u/Asleep-Land-3914 4d ago
Don't you have an AI to sort it out?
2
6
u/Drugba 3d 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.