@pi-unipi/subagents 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -205,6 +205,7 @@ describe("Badge generation — event bus (CRITICAL FIX)", () => {
|
|
|
205
205
|
const validLifecycleEvents = [
|
|
206
206
|
"session_start", "session_shutdown", "input",
|
|
207
207
|
"tool_call", "tool_execution_start",
|
|
208
|
+
"agent_end", "before_agent_start",
|
|
208
209
|
];
|
|
209
210
|
|
|
210
211
|
// Check that pi.on() is only used with lifecycle events
|
|
@@ -228,11 +229,26 @@ describe("Badge generation — event bus (CRITICAL FIX)", () => {
|
|
|
228
229
|
// ─── Test: Event flow ──────────────────────────────────────────────
|
|
229
230
|
|
|
230
231
|
describe("Badge generation — event flow", () => {
|
|
231
|
-
it("utility emits BADGE_GENERATE_REQUEST
|
|
232
|
+
it("utility emits BADGE_GENERATE_REQUEST after agent responds (deferred from input)", () => {
|
|
232
233
|
const src = readSource("packages/utility/src/index.ts");
|
|
233
234
|
|
|
235
|
+
// BADGE_GENERATE_REQUEST should be emitted in agent_end handler, not input
|
|
234
236
|
assert.ok(src.includes("BADGE_GENERATE_REQUEST"));
|
|
235
237
|
assert.ok(src.includes('source: "input-hook"'));
|
|
238
|
+
|
|
239
|
+
// input handler should NOT emit BADGE_GENERATE_REQUEST directly
|
|
240
|
+
const inputBlock = src.match(/pi\.on\("input"[\s\S]*?(?=pi\.on\(|$)/)?.[0] ?? "";
|
|
241
|
+
assert.ok(
|
|
242
|
+
!inputBlock.includes("BADGE_GENERATE_REQUEST"),
|
|
243
|
+
"input handler should NOT emit BADGE_GENERATE_REQUEST — deferred to agent_end",
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
// agent_end handler should emit BADGE_GENERATE_REQUEST
|
|
247
|
+
const agentEndBlock = src.match(/pi\.on\("agent_end"[\s\S]*?(?=pi\.on\(|$)/)?.[0] ?? "";
|
|
248
|
+
assert.ok(
|
|
249
|
+
agentEndBlock.includes("BADGE_GENERATE_REQUEST"),
|
|
250
|
+
"agent_end handler should emit BADGE_GENERATE_REQUEST with full conversation context",
|
|
251
|
+
);
|
|
236
252
|
});
|
|
237
253
|
|
|
238
254
|
it("BADGE_GENERATE_REQUEST event is defined in core", () => {
|
package/src/agent-runner.ts
CHANGED
|
@@ -172,12 +172,16 @@ export async function runAgent(
|
|
|
172
172
|
let toolNames = getToolNamesForType(type, agentConfig);
|
|
173
173
|
|
|
174
174
|
// Create resource loader
|
|
175
|
+
// Respect agentConfig.extensions/skills flags: if explicitly false, skip loading.
|
|
176
|
+
// This prevents explore/work agents from loading all parent extensions.
|
|
175
177
|
const agentDir = getAgentDir();
|
|
178
|
+
const skipExtensions = options.isolated || agentConfig?.extensions === false;
|
|
179
|
+
const skipSkills = options.isolated || agentConfig?.skills === false;
|
|
176
180
|
const loader = new DefaultResourceLoader({
|
|
177
181
|
cwd: effectiveCwd,
|
|
178
182
|
agentDir,
|
|
179
|
-
noExtensions:
|
|
180
|
-
noSkills:
|
|
183
|
+
noExtensions: skipExtensions,
|
|
184
|
+
noSkills: skipSkills,
|
|
181
185
|
noPromptTemplates: true,
|
|
182
186
|
noThemes: true,
|
|
183
187
|
noContextFiles: true,
|
|
@@ -213,15 +217,19 @@ export async function runAgent(
|
|
|
213
217
|
});
|
|
214
218
|
session.setActiveToolsByName(activeTools);
|
|
215
219
|
|
|
216
|
-
// Bind extensions
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
// Bind extensions — only if extensions were loaded.
|
|
221
|
+
// Skipping for agents with extensions: false avoids firing session_start
|
|
222
|
+
// on an empty extension set, preventing unnecessary MODULE_READY cascade.
|
|
223
|
+
if (!skipExtensions) {
|
|
224
|
+
await session.bindExtensions({
|
|
225
|
+
onError: (err) => {
|
|
226
|
+
options.onToolActivity?.({
|
|
227
|
+
type: "end",
|
|
228
|
+
toolName: `extension-error:${err.extensionPath}`,
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
}
|
|
225
233
|
|
|
226
234
|
options.onSessionCreated?.(session);
|
|
227
235
|
|