| 77 | } |
| 78 | |
| 79 | func (l *lineageHeadersInterceptor) Before(ctx context.Context, req *a2aclient.Request) (context.Context, error) { |
| 80 | parent, _ := ctx.Value(parentContextIDContextKey{}).(string) |
| 81 | if parent == "" { |
| 82 | return ctx, nil |
| 83 | } |
| 84 | |
| 85 | var inboundRoot string |
| 86 | if callCtx, ok := a2asrv.CallContextFrom(ctx); ok { |
| 87 | if meta := callCtx.RequestMeta(); meta != nil { |
| 88 | if vals, ok := meta.Get(RootContextIDHeader); ok && len(vals) > 0 { |
| 89 | inboundRoot = vals[0] |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | root := inboundRoot |
| 95 | if root == "" { |
| 96 | root = parent |
| 97 | } |
| 98 | |
| 99 | if len(req.Meta.Get(ParentContextIDHeader)) == 0 { |
| 100 | req.Meta.Append(ParentContextIDHeader, parent) |
| 101 | } |
| 102 | if len(req.Meta.Get(RootContextIDHeader)) == 0 { |
| 103 | req.Meta.Append(RootContextIDHeader, root) |
| 104 | } |
| 105 | return ctx, nil |
| 106 | } |
| 107 | |
| 108 | // authzForwardingInterceptor forwards the Authorization header from the |
| 109 | // incoming A2A request context to outbound sub-agent A2A calls. |