Skip to content

Name an agent profile in me from its person record - #784

Merged
jeremy merged 1 commit into
mainfrom
fix-me-agent-profile
Sep 30, 2026
Merged

jeremy merged 1 commit into
mainfrom
fix-me-agent-profile

Conversation

@jeremy

@jeremy jeremy commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Fixes the issue reported on this card: basecamp me -P <agent-profile> fails with "Authorization failed: invalid or expired token".

What was wrong

me always asked /authorization.json who the credential belongs to. For an agent profile that is Basecamp's own /authorization.json (not Launchpad: AuthorizationEndpointFor("agent") already routes to the Basecamp origin). But that endpoint authenticates through authenticate_basecamp_identity, which requires token.identity_id, and a client_credentials self-token is minted with an agent and an account, with no identity. So the server answers 401 to a perfectly good token. The CLI then attached the agent login remedy (... | basecamp auth login --with-client-credentials ...), which is the right remedy for a broken agent credential but useless here, since re-minting produces another token the endpoint refuses in the same way.

What changed

  • For a stored oauth_type: agent credential, me reads /{account}/my/profile.json in the configured account (the same record connect setup reads through SDKReader.Me) and never calls /authorization.json. No 401 means no misleading hint. A real auth failure on the profile read still gets the agent login remedy, which is right in that case.
  • Agent output: person (id, name, email), accounts holding the one bound account marked current, and no identity (an agent has none). Summary: Name <email> - agent in Basecamp account N.
  • MeOutput.Identity is now a pointer with omitempty so the agent case can leave it out. For every other profile it is always set, so the JSON is byte-for-byte what it was.
  • Under BASECAMP_TOKEN the stored type says nothing about the token being sent, so that path is unchanged.
  • The agent path does not write the accounts completion cache (it knows only the account id) and does not write the person back into the stored credential.

Tests

TestMeOnAnAgentProfileReadsTheAgentsPerson stores an agent credential against a fake server whose /authorization.json answers 401. It asserts me asks only /555/my/profile.json and checks the summary and JSON shape. On main it fails with Authorization failed: invalid or expired token: Run: basecamp auth login, the error from the report.

Not changed here

auth status --check and doctor's "API Connectivity" check also probe /authorization.json with the active credential, so they probably report an agent's valid token as rejected in the same way. I left them out to keep this change scoped to the report. They could get the same agent branch, or /authorization.json in bc3 could learn to describe agent tokens, which would fix all three at once.


Summary by cubic

Fixes basecamp me -P <agent-profile> failing with "Authorization failed: invalid or expired token" for agent credentials. Agent self-tokens have no identity, so /authorization.json rejects them; me now reads the agent's person record from /{account}/my/profile.json instead, outputs that person and the bound account, and omits identity. Other profiles and the BASECAMP_TOKEN path are untouched, but auth status --check and doctor's API connectivity check still probe /authorization.json and may report agent tokens as rejected.

Written for commit 0276079. Summary will update on new commits.

Review in cubic

An agent's self-token has no identity behind it, so Basecamp's
/authorization.json answers it 401 and `basecamp me -P <agent>` failed
with "Authorization failed: invalid or expired token" and a hint to
re-run the client-credentials login, which cannot help: the token is
fine, the endpoint just does not serve agents.

For a stored agent credential, `me` now reads /{account}/my/profile.json
in the account the agent is bound to, the same record `connect setup`
already reads. The output carries the person and that one account, and
omits identity. Other profiles, and anything under BASECAMP_TOKEN, take
the authorization document path as before, with unchanged JSON.
Copilot AI balanced review requested due to automatic review settings September 22, 2026 22:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T22:18:10.138844Z 0276079 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added commands CLI command implementations tests Tests (unit and e2e) labels Sep 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approved

The focused implementation correctly preserves existing behavior and covers the new agent path.

Review effort: Balanced
Findings: None

What changed in this PR

Updates basecamp me to support agent credentials without querying the incompatible authorization endpoint.

Changes:

  • Retrieves agent identity from the account-scoped person endpoint.
  • Omits nonexistent agent identity data while reporting its bound account.
  • Adds coverage for agent routing and JSON output.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
internal/​commands/​people.go Adds agent-specific profile retrieval and output.
internal/​commands/​people_test.go Verifies endpoint routing, summary, and JSON shape.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jeremy
jeremy added this pull request to stack #801 September 30, 2026 03:32
@jeremy
jeremy merged commit 1784b8f into main Sep 30, 2026
31 checks passed
@jeremy
jeremy deleted the fix-me-agent-profile branch September 30, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands CLI command implementations tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants