resolveSource looks up the agent source for agentFilename. An exact match is always preferred so that distinct variants served side by side (e.g. two gordonTag values in the same process) keep their own sources. When there is no exact match, it falls back to matching on a stable identity that ignor
(agentFilename string)
| 1034 | // the same stable identity, resolving would be a guess, so it returns the |
| 1035 | // not-found error instead of silently picking one. |
| 1036 | func (sm *SessionManager) resolveSource(agentFilename string) (config.Source, error) { |
| 1037 | if agentSource, found := sm.Sources[agentFilename]; found { |
| 1038 | return agentSource, nil |
| 1039 | } |
| 1040 | |
| 1041 | want := config.StableSourceKey(agentFilename) |
| 1042 | var match config.Source |
| 1043 | var matches int |
| 1044 | for key, source := range sm.Sources { |
| 1045 | if config.StableSourceKey(key) == want { |
| 1046 | match = source |
| 1047 | matches++ |
| 1048 | } |
| 1049 | } |
| 1050 | if matches == 1 { |
| 1051 | return match, nil |
| 1052 | } |
| 1053 | |
| 1054 | return nil, fmt.Errorf("agent not found: %s", agentFilename) |
| 1055 | } |
| 1056 | |
| 1057 | // applyRunModelOverride applies modelRef as the per-agent model override |
| 1058 | // on the session backing rs. It mirrors the in-memory mutations that |