feat: add stable agentId to uipath.json for packaging and spans#1695
feat: add stable agentId to uipath.json for packaging and spans#1695radu-mocanu wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a stable agentId stored in uipath.json and wires it through project initialization, packaging (operate.json projectId), and LLMOps span attributes to enable consistent correlation across authoring, packaging, and runtime.
Changes:
- Add
agentIdto theuipath.jsonschema and mint/backfill it duringuipath init(preserving existing values). - Update
uipath packto sourceoperate.json#projectIdfromuipath.json#agentId, with fallback to legacy.uipath/.telemetry.jsonProjectKey. - Update span attribute resolution to prefer cached
uipath.json#agentId, falling back toPROJECT_KEY, and add/adjust tests accordingly.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/uipath/src/uipath/_cli/models/uipath_json_schema.py | Adds agentId field to the typed uipath.json configuration model. |
| packages/uipath/src/uipath/_cli/cli_init.py | Mints/backfills agentId into uipath.json during uipath init. |
| packages/uipath/src/uipath/_cli/_utils/_project_files.py | Introduces resolve_existing_project_id() to reuse Studio Web/env or legacy telemetry ProjectKey. |
| packages/uipath/src/uipath/_cli/cli_pack.py | Switches packaging to use agentId as projectId and removes old inline telemetry lookup. |
| packages/uipath/tests/cli/test_init.py | Adds coverage for minting/backfilling/preserving agentId across init scenarios. |
| packages/uipath/tests/cli/test_pack.py | Adds coverage for projectId sourcing from agentId and legacy telemetry fallback. |
| packages/uipath-platform/src/uipath/platform/common/_span_utils.py | Adds cached read of agentId from uipath.json and uses it for span agentId. |
| packages/uipath-platform/tests/services/test_span_utils.py | Adds tests for agentId resolution priority and caching behavior; clears cache between tests. |
| packages/uipath/pyproject.toml | Bumps uipath version. |
| packages/uipath/uv.lock | Updates lockfile metadata / versions. |
| packages/uipath-platform/pyproject.toml | Bumps uipath-platform version. |
| packages/uipath-platform/uv.lock | Updates lockfile metadata / versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # prefer agentId from uipath.json; fall back to the legacy | ||
| # .telemetry.json or SW project id. | ||
| project_id = config.agent_id or resolve_existing_project_id() or str(uuid.uuid4()) | ||
|
|
| operate_file = generate_operate_file( | ||
| entrypoints, config_data.runtime_options, dependencies | ||
| ) | ||
| operate_file = generate_operate_file(entrypoints, config_data, dependencies) |
3f97eac to
c5bb52b
Compare
RobinMennens-UiPath
left a comment
There was a problem hiding this comment.
Took a pass focused on the agentId behavior across the coded agent types, regressions, and the spans. Two things I'd like to align on before this goes in:
For plain functions and declarative agents this is end-to-end correct. But langgraph/llamaindex agents build their own operate.json in the plugin repos and won't source projectId from uipath.json#agentId until we mirror this there. Is there a follow-up tracking that, or is the expectation that those plugins start reading uipath.json#agentId?
Separately, on alignment with the vertical-solutions-check-agent-id.yml check: that check looks for a coded agent's ID only in .uipath/.telemetry.json#ProjectKey or .uipath/local-project-id.json#projectId — not in uipath.json#agentId. With telemetry disabled, create_telemetry_config_file doesn't write .telemetry.json, and we don't write local-project-id.json either, so an agent inited by this PR would have its ID only in uipath.json and the CI check would report it as missing. Are we updating that check to read uipath.json#agentId too, or should init also write one of the files it expects? These two need to agree.
This is not true. |
This is not a concern for the coded agents SDK. the changes are backwards compatible, meaning that existing IDs will still be honored. newly created agents will indeed drop |
c5bb52b to
47096b4
Compare
🚨 Heads up:
|
|
alexandra-c
left a comment
There was a problem hiding this comment.
Could we extend this to cover function project types as well? agentId isn't the right name for a coded function, could we detect the project type and use functionId accordingly, or pick a generic name that works for both?
If you ask me, everything that can run on the UiPath platform should have a unique GUID identifier that never changes. RPA, coded functions, coded agents, low code agents, etc. |
Agreed. the problem is that we already have a ProjectKey (similar to project id, that is the release key from orchestrator). to be consistent with the agentId naming (which is already the established field for low code agents today) I would use functionId for functions. I will also consult with the team regarding this since it would be a spec decision |
IMO every product should define its own GUID (I imagine you'll need this exposed downstream at some point). For Agents we are exposing a concrete AgentIId which must be separate from ProjectId (because of flow) so the generic approach might not work well unless you also include a discriminator, but at that point having separate IDs is probably similar overhead @jepadil23 FYI this is similar to what we are solving for Trace service ID hierarchy |
jepadil23
left a comment
There was a problem hiding this comment.
idea LGTM, only resolve if possible build issues




Summary
uipath initmints a stableagentIdintouipath.json, preserved across re-init and backfilled for existing projectsuipath packsources the packageprojectIdfromuipath.json#agentId, falling back to the legacy.telemetry.jsonProjectKeyagentIdread fromuipath.json(cached), falling back to thePROJECT_KEYenv varagentIdstring, not the wholeuipath.json(immutable value, no shared-mutable-cache footgun)Why
a coded agent needs one stable identifier that survives authoring, packaging, and runtime so traces and deployed releases correlate back to the same agent. anchoring it in
uipath.jsonalso decouples the id from telemetry being enabled.