| 1 | package agent |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | |
| 6 | "reasonix/internal/capability" |
| 7 | "reasonix/internal/tool" |
| 8 | ) |
| 9 | |
| 10 | // contextualEntry overlays live availability on a copy. The cached catalog |
| 11 | // and its fingerprint stay stable; discovery cannot authorize a later call, |
| 12 | // which must recheck the same tool contract at execution time. |
| 13 | func (t *UseCapabilityTool) contextualEntry(ctx context.Context, entry capability.Entry) capability.Entry { |
| 14 | if entry.Kind != capability.KindTool || entry.Status != capability.StatusReady || t.registry == nil { |
| 15 | return entry |
| 16 | } |
| 17 | if target, ok := t.registry.Get(entry.ToolName); ok { |
| 18 | if reason := tool.ContextualUnavailableReason(ctx, target); reason != "" { |
| 19 | entry.Status = capability.StatusDisabled |
| 20 | entry.FailureReason = reason |
| 21 | } |
| 22 | } |
| 23 | return entry |
| 24 | } |
| 25 |