SIGN IN SIGN UP

fix(otel): ensure nested context object creates separate attribute (#15655)

## Background

for a nested runtime context defined as

```ts
runtimeContext: {
  userId: 'user-123',
  metadata: {
    tenant: 'acme',
    plan: 'pro',
  },
}
```

the spans we produced looked like

```
{
  'ai.settings.context.userId': 'user-123',
  'ai.settings.context.metadata': { tenant: 'acme', plan: 'pro' },
}
```

but the second attribute, which is an object, is not a valid
OpenTelemetry span attribute value, so real OTel exporters drop it.
Which would result in traces like

```
{
  'ai.settings.context.userId': 'user-123',
}
``` 

## Summary

After the change, nested context is flattened into valid primitive
attributes:

```
{
  'ai.settings.context.userId': 'user-123',
  'ai.settings.context.metadata.tenant': 'acme',
  'ai.settings.context.metadata.plan': 'pro',
}
```

## Manual Verification

na

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)
A
Aayush Kapoor committed
1e200eb137d9ff9696046816059ef0100d245ebd
Parent: cd3de8b
Committed by GitHub <noreply@github.com> on 5/27/2026, 9:55:07 PM