( ctx context.Context, req toolspkg.CallRequest, location memoryToolLocation, actorKind nativeMemoryActorKind, targetID string, )
| 5339 | } |
| 5340 | |
| 5341 | func (n *daemonNativeTools) denySubagentMemoryWrite( |
| 5342 | ctx context.Context, |
| 5343 | req toolspkg.CallRequest, |
| 5344 | location memoryToolLocation, |
| 5345 | actorKind nativeMemoryActorKind, |
| 5346 | targetID string, |
| 5347 | ) error { |
| 5348 | if actorKind != nativeMemoryActorKindSubagent { |
| 5349 | return nil |
| 5350 | } |
| 5351 | cause := fmt.Errorf("%w: sub-agent memory writes are denied", toolspkg.ErrToolDenied) |
| 5352 | if location.Store != nil { |
| 5353 | if err := location.Store.RecordMemoryWriteRejected(ctx, memorypkg.WriteRejectedEvent{ |
| 5354 | Scope: location.Scope, |
| 5355 | WorkspaceID: location.WorkspaceID, |
| 5356 | AgentName: location.AgentName, |
| 5357 | AgentTier: location.AgentTier, |
| 5358 | SessionID: strings.TrimSpace(req.SessionID), |
| 5359 | ActorKind: string(actorKind), |
| 5360 | TargetID: targetID, |
| 5361 | Reason: string(toolspkg.ReasonMemorySubagentWriteDenied), |
| 5362 | ToolID: string(req.ToolID), |
| 5363 | }); err != nil { |
| 5364 | cause = errors.Join(cause, err) |
| 5365 | } |
| 5366 | } |
| 5367 | return toolspkg.NewToolError( |
| 5368 | toolspkg.ErrorCodeDenied, |
| 5369 | req.ToolID, |
| 5370 | "sub-agent memory writes are denied", |
| 5371 | cause, |
| 5372 | toolspkg.ReasonMemorySubagentWriteDenied, |
| 5373 | ) |
| 5374 | } |
| 5375 | |
| 5376 | func (n *daemonNativeTools) recordMemoryToolWrite( |
| 5377 | scope toolspkg.Scope, |
no test coverage detected