Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

Implements the Agent Settings API for managing agent configuration templates by type and instance-specific settings.

Changes

  • AgentSettingsService - New service class in @microsoft/agents-a365-runtime with methods:

    • getAgentSettingTemplate/setAgentSettingTemplate - Manage templates by agent type
    • getAgentSettings/setAgentSettings - Manage settings by agent instance ID
  • Type definitions - AgentSettingTemplate and AgentSettings interfaces with settings as Record<string, unknown> and optional metadata

  • Endpoints - Constructs Power Platform API URLs:

    • /agents/v1.0/settings/templates/{agentType}
    • /agents/v1.0/settings/instances/{agentInstanceId}

Usage

import { AgentSettingsService, PowerPlatformApiDiscovery } from '@microsoft/agents-a365-runtime';

const service = new AgentSettingsService(
  new PowerPlatformApiDiscovery('prod'),
  tenantId
);

// Manage templates
const template = await service.getAgentSettingTemplate('my-agent-type', token);
await service.setAgentSettingTemplate({
  agentType: 'my-agent-type',
  settings: { key: 'value' }
}, token);

// Manage instance settings
const settings = await service.getAgentSettings('instance-id', token);
await service.setAgentSettings({
  agentInstanceId: 'instance-id',
  agentType: 'my-agent-type',
  settings: { instanceKey: 'value' }
}, token);
Original prompt

Implementing the Agents Settings for NodeJS

See attached swagger file for more information on this API.

This currently API supports:

GET or SET agent setting template by agent type

GET or SET agent settings by agent instance.

https://github.com/user-attachments/files/23107469/swagger.json


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Implement agent settings API for NodeJS Add Agent Settings Service with template and instance management Jan 5, 2026
Copilot AI requested a review from sergioescalera January 5, 2026 18:01
@sergioescalera sergioescalera added the codegen-experiment AI First experimentation label Jan 5, 2026
@sergioescalera sergioescalera marked this pull request as ready for review January 5, 2026 19:19
@sergioescalera sergioescalera requested a review from a team as a code owner January 5, 2026 19:19
Copilot AI review requested due to automatic review settings January 5, 2026 19:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds the Agent Settings Service to the @microsoft/agents-a365-runtime package, implementing API methods for managing agent configuration templates by type and instance-specific settings. The implementation provides both template-level and instance-level CRUD operations via the Power Platform API.

  • Introduces AgentSettingsService class with methods for getting/setting templates and instance settings
  • Defines TypeScript interfaces (AgentSettingTemplate and AgentSettings) with flexible key-value settings and optional metadata
  • Includes comprehensive test suite with mocking, error handling tests, and endpoint verification
  • Updates documentation with usage examples

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/agents-a365-runtime/src/agent-settings-service.ts New service implementing template and instance settings management with Power Platform API integration
packages/agents-a365-runtime/src/index.ts Exports the new AgentSettingsService and related types
tests/runtime/agent-settings-service.test.ts Comprehensive test suite covering CRUD operations, error handling, and endpoint construction
packages/agents-a365-runtime/README.md Documentation with usage examples for the Agent Settings Service

Comment on lines +107 to +122
const response = await fetch(endpoint, {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
});

if (!response.ok) {
throw new Error(
`Failed to get agent setting template for type '${agentType}': ${response.status} ${response.statusText}`
);
}

return await response.json();
}
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The fetch call lacks error handling for network failures and JSON parsing errors. If the network request fails (e.g., network timeout, DNS failure) or if the response body is not valid JSON, an unhandled exception will be thrown. Consider wrapping the fetch and json parsing in a try-catch block to provide more informative error messages to callers.

Copilot uses AI. Check for mistakes.
Comment on lines +136 to +152
const response = await fetch(endpoint, {
method: 'PUT',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(template),
});

if (!response.ok) {
throw new Error(
`Failed to set agent setting template for type '${template.agentType}': ${response.status} ${response.statusText}`
);
}

return await response.json();
}
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The fetch call lacks error handling for network failures and JSON parsing errors. If the network request fails (e.g., network timeout, DNS failure) or if the response body is not valid JSON, an unhandled exception will be thrown. Consider wrapping the fetch and json parsing in a try-catch block to provide more informative error messages to callers.

Copilot uses AI. Check for mistakes.
Comment on lines +166 to +181
const response = await fetch(endpoint, {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
});

if (!response.ok) {
throw new Error(
`Failed to get agent settings for instance '${agentInstanceId}': ${response.status} ${response.statusText}`
);
}

return await response.json();
}
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The fetch call lacks error handling for network failures and JSON parsing errors. If the network request fails (e.g., network timeout, DNS failure) or if the response body is not valid JSON, an unhandled exception will be thrown. Consider wrapping the fetch and json parsing in a try-catch block to provide more informative error messages to callers.

Copilot uses AI. Check for mistakes.
Comment on lines +195 to +211
const response = await fetch(endpoint, {
method: 'PUT',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(settings),
});

if (!response.ok) {
throw new Error(
`Failed to set agent settings for instance '${settings.agentInstanceId}': ${response.status} ${response.statusText}`
);
}

return await response.json();
}
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The fetch call lacks error handling for network failures and JSON parsing errors. If the network request fails (e.g., network timeout, DNS failure) or if the response body is not valid JSON, an unhandled exception will be thrown. Consider wrapping the fetch and json parsing in a try-catch block to provide more informative error messages to callers.

Copilot uses AI. Check for mistakes.
Comment on lines +338 to +351
it.each<{ cluster: ClusterCategory; expectedDomain: string }>([
{ cluster: 'prod', expectedDomain: 'api.powerplatform.com' },
{ cluster: 'gov', expectedDomain: 'api.gov.powerplatform.microsoft.us' },
{ cluster: 'high', expectedDomain: 'api.high.powerplatform.microsoft.us' },
])('should construct endpoint with correct domain for $cluster cluster', ({ cluster, expectedDomain }) => {
const discovery = new PowerPlatformApiDiscovery(cluster);
const testService = new AgentSettingsService(discovery, testTenantId);

const endpoint = testService.getAgentSettingTemplateEndpoint(testAgentType);

expect(endpoint).toContain(expectedDomain);
expect(endpoint).toContain('/agents/v1.0/settings/templates/');
});
});
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The cluster category test coverage is incomplete. Only 3 of the 13 supported cluster categories are tested (prod, gov, high), while PowerPlatformApiDiscovery supports 13 categories (local, dev, test, preprod, firstrelease, prod, gov, high, dod, mooncake, ex, rx). Following the pattern in power-platform-api-discovery.test.ts, consider testing all cluster categories or at least a more representative subset to ensure the service works correctly across all environments.

Copilot uses AI. Check for mistakes.
@sergioescalera
Copy link

🤖 SDK Parity Automation

Summary

This PR modifies the Node.js/TypeScript SDK. To maintain feature parity across all SDKs, Existing open parity issues were found:

What happens next?

  1. Parity issues ready: GitHub Copilot agent (copilot-swe-agent) is assigned to these issues
  2. 🤖 Copilot will work on them: The agent will analyze your changes and generate corresponding PRs for each target SDK
  3. 👀 Review required: Once Copilot creates the PRs, they will need human review before merging

Need to skip parity?

If parity is not needed for a particular SDK, close the corresponding issue with the wontfix label.


Automated by AI-First Polling Workflow

@sergioescalera sergioescalera marked this pull request as draft January 7, 2026 23:34
@sergioescalera sergioescalera removed the codegen-experiment AI First experimentation label Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants