Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(maker-core): use wire model for output guard
ZJPexcde8743577bd
diff --git a/packages/maker-core/src/agents/pi/__tests__/pi-startsession-cleanup.test.ts b/packages/maker-core/src/agents/pi/__tests__/pi-startsession-cleanup.test.tsindex 7faf8b376f..2a5899d18a 100644--- a/packages/maker-core/src/agents/pi/__tests__/pi-startsession-cleanup.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/pi-startsession-cleanup.test.ts@@ -248,6 +248,36 @@ describe('PiAgent.startSession failure cleanup (mocked pi process)', () => {model: 'm',});+ function emitConfirmedDegenerateOutput(): void {+ knobs.onEvent?.({ type: 'agent_start' });+ knobs.onEvent?.({ type: 'message_start' });+ const repeated = 'let me write the file now; 现在执行;落地。'.repeat(1_100);+ knobs.onEvent?.({+ type: 'message_update',+ assistantMessageEvent: {+ type: 'text_delta',+ contentIndex: 0,+ delta: repeated.slice(0, 16_384),+ },+ });+ knobs.onEvent?.({+ type: 'message_update',+ assistantMessageEvent: {+ type: 'text_delta',+ contentIndex: 0,+ delta: repeated.slice(16_384, 20_480),+ },+ });+ knobs.onEvent?.({+ type: 'message_update',+ assistantMessageEvent: {+ type: 'text_delta',+ contentIndex: 0,+ delta: repeated.slice(20_480),+ },+ });+ }+it('disposes ctx (and does not close a nonexistent proc) when the process constructor throws synchronously', async () => {knobs.ctorThrows = true;const agent = new PiAgent(buildDeps());@@ -464,6 +494,72 @@ describe('PiAgent.startSession failure cleanup (mocked pi process)', () => {await handle.close();});+ it('enables DeepSeek output protection from the resolved wire model', async () => {+ const publicModel = 'legacy-model';+ const providerId = 'native-alias';+ const handle = await new PiAgent(buildDeps({+ capabilityAdditions: {+ availableModels: [{+ id: publicModel,+ displayName: publicModel,+ contextWindow: 200_000,+ efforts: [],+ defaultEffort: null,+ }],+ },+ resolvePiNativeProviders: async () => ({+ providers: [{+ id: providerId,+ name: 'Native Alias',+ baseUrl: 'https://native.example.test/v1',+ api: 'openai-responses',+ modelIdAliases: { [publicModel]: 'deepseek-native' },+ models: [{ id: 'deepseek-native', wireId: 'deepseek/deepseek-v4-pro' }],+ }],+ env: {},+ }),+ })).startSession({ ...opts(), model: publicModel, providerId });+ knobs.requests = [];++ emitConfirmedDegenerateOutput();++ await vi.waitFor(() => expect(knobs.requests.filter((type) => type === 'abort')).toHaveLength(1));+ await handle.close();+ });++ it('does not enable DeepSeek output protection when the wire model is not DeepSeek', async () => {+ const publicModel = 'deepseek-public';+ const providerId = 'native-alias';+ const handle = await new PiAgent(buildDeps({+ capabilityAdditions: {+ availableModels: [{+ id: publicModel,+ displayName: publicModel,+ contextWindow: 200_000,+ efforts: [],+ defaultEffort: null,+ }],+ },+ resolvePiNativeProviders: async () => ({+ providers: [{+ id: providerId,+ name: 'Native Alias',+ baseUrl: 'https://native.example.test/v1',+ api: 'openai-responses',+ modelIdAliases: { [publicModel]: 'deepseek-native' },+ models: [{ id: 'deepseek-native', wireId: 'neutral/model-v1' }],+ }],+ env: {},+ }),+ })).startSession({ ...opts(), model: publicModel, providerId });+ knobs.requests = [];++ emitConfirmedDegenerateOutput();++ expect(knobs.requests.filter((type) => type === 'abort')).toHaveLength(0);+ await handle.close();+ });+it('allows an explicitly requested repetitive Pi turn without weakening the next turn', async () => {const deepSeekModel = 'DeepSeek-V4-Flash-0731';const handle = await new PiAgent(buildDeps({diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.tsindex 972113a091..e2ee8397de 100644--- a/packages/maker-core/src/agents/pi/index.ts+++ b/packages/maker-core/src/agents/pi/index.ts@@ -2277,9 +2277,10 @@ export class PiAgent extends BaseAgent {let proc: PiRpcProcess;const outputDegenerationProtection = new PiOutputDegenerationProtection({logger: this.deps.logger.child('output-degeneration'),- // 读取 mutableModel 而不是启动快照:会话内 setModel 后下一条消息立即按新模型生效。+ // 读取实际下发给 Pi 的 mutableWireModel:既遵守 provider alias / wireId,+ // 也让会话内 setModel 后的下一条消息立即按新模型生效。isEnabled: () =>- shouldProtectPiOutput(mutableModel) && !activeOutputDegenerationBypass,+ shouldProtectPiOutput(mutableWireModel) && !activeOutputDegenerationBypass,abort: () => proc.request({ type: 'abort' }),onDetected: () => markPiOutputDegeneration(ctx),});