fix(pi): serialize write-leased tool batches
This commit is contained in:
@@ -46,6 +46,7 @@ function configureNetwork(settingsManager) {
|
||||
|
||||
const SERVER_CHANNEL = '@makelore/server';
|
||||
const PROTOCOL_VERSION = 1;
|
||||
const PROJECT_WRITE_LEASE_TOOL_NAMES = new Set(['bash', 'edit', 'write']);
|
||||
const threads = new Map();
|
||||
const openingThreads = new Set();
|
||||
let shuttingDown = false;
|
||||
@@ -106,6 +107,14 @@ function referencedEnvironmentNames(value) {
|
||||
return names;
|
||||
}
|
||||
|
||||
function serializeProjectWriteLeaseTools(session) {
|
||||
session.agent.state.tools = session.agent.state.tools.map((tool) => (
|
||||
PROJECT_WRITE_LEASE_TOOL_NAMES.has(tool.name) && tool.executionMode !== 'sequential'
|
||||
? { ...tool, executionMode: 'sequential' }
|
||||
: tool
|
||||
));
|
||||
}
|
||||
|
||||
async function credentialStoreFor(options, providerId) {
|
||||
const models = JSON.parse(await readFile(path.join(options.configDir, 'models.json'), 'utf8'));
|
||||
const provider = record(record(models)?.providers)?.[providerId];
|
||||
@@ -368,6 +377,12 @@ class AgentThread {
|
||||
|
||||
async rebind() {
|
||||
const session = this.runtime.session;
|
||||
// Pi prepares every tool_call hook before starting a parallel tool batch.
|
||||
// Makelore acquires its project write lease in that hook and releases it in
|
||||
// tool_result, so two parallel mutation tools would otherwise wait on each
|
||||
// other before either command can start. Mark only the built-in mutation
|
||||
// tools sequential; read-only batches retain Pi's parallel execution.
|
||||
serializeProjectWriteLeaseTools(session);
|
||||
await session.bindExtensions({
|
||||
uiContext: this.createExtensionUiContext(),
|
||||
mode: 'rpc',
|
||||
|
||||
Reference in New Issue
Block a user