GeezerVison is showing github.com — fix(acp-registry): keep provisional model-specific options off retain… · pingdotgg/t3code@dc8adf1
File treeExpand file treeCollapse file tree Open diff view settings packages/provider-acp-registry/src/server
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/provider-acp-registry/src/server/driver.test.ts +89-12Lines changed: 89 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -771,12 +771,41 @@ describe("acpRegistrySnapshotReadiness", () => { | 771 | 771 | "auto", | 772 | 772 | ); | 773 | 773 |
| | 774 | + const entitledEffort = { | | 775 | + id: "effort", | | 776 | + label: "Effort", | | 777 | + type: "select" as const, | | 778 | + currentValue: "high", | | 779 | + options: [ | | 780 | + { id: "low", label: "Low" }, | | 781 | + { id: "high", label: "High" }, | | 782 | + ], | | 783 | + }; | | 784 | + const placeholderEffort = { | | 785 | + id: "effort", | | 786 | + label: "Effort", | | 787 | + type: "select" as const, | | 788 | + currentValue: "on", | | 789 | + options: [ | | 790 | + { id: "off", label: "Off" }, | | 791 | + { id: "on", label: "On" }, | | 792 | + ], | | 793 | + }; | | 794 | + const sharedMode = { | | 795 | + id: "mode", | | 796 | + label: "Mode", | | 797 | + type: "select" as const, | | 798 | + currentValue: "code", | | 799 | + options: [{ id: "code", label: "Code" }], | | 800 | + }; | | 801 | + | 774 | 802 | const entitled = applyAcpRegistryLiveConfiguration( | 775 | 803 | provider, | 776 | 804 | { | 777 | 805 | models: [{ id: "gmodel", name: "GPT-Pro", description: null }], | 778 | 806 | currentModelId: "gmodel", | 779 | | - configOptions: [], | | 807 | + configOptions: [entitledEffort], | | 808 | + modelOptionIds: ["effort"], | 780 | 809 | modelsFromModelSelect: true, | 781 | 810 | }, | 782 | 811 | [], | @@ -789,7 +818,8 @@ describe("acpRegistrySnapshotReadiness", () => { | 789 | 818 | { | 790 | 819 | models: [{ id: "placeholder", name: "Placeholder", description: null }], | 791 | 820 | currentModelId: "placeholder", | 792 | | - configOptions: [], | | 821 | + configOptions: [placeholderEffort, sharedMode], | | 822 | + modelOptionIds: ["effort"], | 793 | 823 | modelsFromModelSelect: false, | 794 | 824 | }, | 795 | 825 | [], | @@ -798,6 +828,24 @@ describe("acpRegistrySnapshotReadiness", () => { | 798 | 828 | ); | 799 | 829 | expect(afterProvisional.models.map((m) => m.slug)).toEqual(["gmodel"]); | 800 | 830 | expect(afterProvisional.models.find((m) => m.slug === "gmodel")?.isDefault).toBe(true); | | 831 | + expect( | | 832 | + afterProvisional.models.find((m) => m.slug === "gmodel")?.capabilities?.optionDescriptors, | | 833 | + ).toEqual([sharedMode, entitledEffort]); | | 834 | + | | 835 | + const afterProvisionalModelOnly = applyAcpRegistryLiveConfiguration( | | 836 | + entitled, | | 837 | + { | | 838 | + models: [{ id: "placeholder", name: "Placeholder", description: null }], | | 839 | + currentModelId: "placeholder", | | 840 | + configOptions: [placeholderEffort], | | 841 | + modelOptionIds: ["effort"], | | 842 | + modelsFromModelSelect: false, | | 843 | + }, | | 844 | + [], | | 845 | + entitled.models, | | 846 | + { preserveSingleModelCatalog: true }, | | 847 | + ); | | 848 | + expect(afterProvisionalModelOnly.models).toBe(entitled.models); | 801 | 849 |
| 802 | 850 | const replacedExplicit = applyAcpRegistryLiveConfiguration( | 803 | 851 | entitled, | @@ -1710,7 +1758,19 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => { | 1710 | 1758 | yield* coordinator.publishLiveConfiguration(identity.instanceId, { | 1711 | 1759 | models: [{ id: "entitled-model", name: "Entitled", description: null }], | 1712 | 1760 | currentModelId: "entitled-model", | 1713 | | - configOptions: [], | | 1761 | + configOptions: [ | | 1762 | + { | | 1763 | + id: "effort", | | 1764 | + label: "Effort", | | 1765 | + type: "select", | | 1766 | + currentValue: "high", | | 1767 | + options: [ | | 1768 | + { id: "low", label: "Low" }, | | 1769 | + { id: "high", label: "High" }, | | 1770 | + ], | | 1771 | + }, | | 1772 | + ], | | 1773 | + modelOptionIds: ["effort"], | 1714 | 1774 | modelsFromModelSelect: true, | 1715 | 1775 | }); | 1716 | 1776 | yield* Fiber.join(liveApplied); | @@ -1730,13 +1790,13 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => { | 1730 | 1790 | ).toEqual(Option.some("entitled-model")); | 1731 | 1791 |
| 1732 | 1792 | // A subsequent provisional single-model live update must not replace the explicit singleton | 1733 | | - // catalog or downgrade its provenance. | | 1793 | + // catalog, overwrite its model-specific options, or downgrade its provenance. | 1734 | 1794 | const provisionalProcessed = yield* instance.snapshot.streamChanges.pipe( | 1735 | 1795 | Stream.filter( | 1736 | 1796 | (snapshot) => | 1737 | 1797 | snapshot.models | 1738 | 1798 | .find((model) => model.slug === "entitled-model") | 1739 | | - ?.capabilities?.optionDescriptors?.some((option) => option.id === "effort") === true, | | 1799 | + ?.capabilities?.optionDescriptors?.some((option) => option.id === "mode") === true, | 1740 | 1800 | ), | 1741 | 1801 | Stream.runHead, | 1742 | 1802 | Effect.forkScoped({ startImmediately: true }), | @@ -1745,24 +1805,41 @@ it.layer(driverLayer)("AcpRegistryDriver periodic refresh", (it) => { | 1745 | 1805 | models: [{ id: "live-placeholder", name: "Live Placeholder", description: null }], | 1746 | 1806 | currentModelId: "live-placeholder", | 1747 | 1807 | configOptions: [ | | 1808 | + { | | 1809 | + id: "mode", | | 1810 | + label: "Mode", | | 1811 | + type: "select", | | 1812 | + currentValue: "code", | | 1813 | + options: [{ id: "code", label: "Code" }], | | 1814 | + }, | 1748 | 1815 | { | 1749 | 1816 | id: "effort", | 1750 | 1817 | label: "Effort", | 1751 | 1818 | type: "select", | 1752 | | - currentValue: "high", | | 1819 | + currentValue: "on", | 1753 | 1820 | options: [ | 1754 | | - { id: "low", label: "Low" }, | 1755 | | - { id: "high", label: "High" }, | | 1821 | + { id: "off", label: "Off" }, | | 1822 | + { id: "on", label: "On" }, | 1756 | 1823 | ], | 1757 | 1824 | }, | 1758 | 1825 | ], | | 1826 | + modelOptionIds: ["effort"], | 1759 | 1827 | modelsFromModelSelect: false, | 1760 | 1828 | }); | | 1829 | + const retainedAfterProvisional = Option.getOrThrow(yield* Fiber.join(provisionalProcessed)); | | 1830 | + expect(retainedAfterProvisional.models.map((model) => model.slug)).toEqual([ | | 1831 | + "entitled-model", | | 1832 | + ]); | 1761 | 1833 | expect( | 1762 | | - Option.getOrThrow(yield* Fiber.join(provisionalProcessed)).models.map( | 1763 | | - (model) => model.slug, | 1764 | | - ), | 1765 | | - ).toEqual(["entitled-model"]); | | 1834 | + retainedAfterProvisional.models | | 1835 | + .find((model) => model.slug === "entitled-model") | | 1836 | + ?.capabilities?.optionDescriptors?.find((option) => option.id === "effort"), | | 1837 | + ).toMatchObject({ | | 1838 | + options: [ | | 1839 | + { id: "low", label: "Low" }, | | 1840 | + { id: "high", label: "High" }, | | 1841 | + ], | | 1842 | + }); | 1766 | 1843 |
| 1767 | 1844 | yield* fileSystem.writeFileString(modelsPath, JSON.stringify({ provisional: "placeholder" })); | 1768 | 1845 | yield* TestClock.adjust("16 minutes"); | |
Collapse file Copy file name to clipboardExpand all lines: packages/provider-acp-registry/src/server/driver.ts +34-12Lines changed: 34 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -455,11 +455,26 @@ export function applyAcpRegistryLiveConfiguration( | 455 | 455 | const useLiveCatalog = | 456 | 456 | configuration.models.length > 1 || | 457 | 457 | (configuration.models.length === 1 && !liveCatalogIsProvisional); | 458 | | - const selectedProbedModelId = | | 458 | + const liveCurrentModelInProbed = | 459 | 459 | configuration.currentModelId !== null && | 460 | | - probedModels.some((model) => model.slug === configuration.currentModelId) | 461 | | - ? configuration.currentModelId | 462 | | - : (probedModels.find((model) => model.isDefault)?.slug ?? null); | | 460 | + probedModels.some((model) => model.slug === configuration.currentModelId); | | 461 | + const selectedProbedModelId = liveCurrentModelInProbed | | 462 | + ? configuration.currentModelId | | 463 | + : (probedModels.find((model) => model.isDefault)?.slug ?? null); | | 464 | + // When retaining the probed catalog for a live session running an absent | | 465 | + // model (e.g. a cold-start placeholder), keep only shared options and leave | | 466 | + // each retained model's own learned options untouched. | | 467 | + const dropUnmatchedModelOptions = | | 468 | + !useLiveCatalog && configuration.currentModelId !== null && !liveCurrentModelInProbed; | | 469 | + const unmatchedModelOptionIds = dropUnmatchedModelOptions | | 470 | + ? new Set(configuration.modelOptionIds ?? []) | | 471 | + : EMPTY_SLUG_SET; | | 472 | + const effectiveConfigOptions = | | 473 | + unmatchedModelOptionIds.size === 0 | | 474 | + ? configuration.configOptions | | 475 | + : configuration.configOptions.filter( | | 476 | + (descriptor) => !unmatchedModelOptionIds.has(descriptor.id), | | 477 | + ); | 463 | 478 | const discovery = useLiveCatalog | 464 | 479 | ? configuration | 465 | 480 | : { | @@ -469,19 +484,26 @@ export function applyAcpRegistryLiveConfiguration( | 469 | 484 | name: model.name, | 470 | 485 | description: null, | 471 | 486 | })), | 472 | | - currentModelId: selectedProbedModelId, | | 487 | + currentModelId: dropUnmatchedModelOptions | | 488 | + ? configuration.currentModelId | | 489 | + : selectedProbedModelId, | | 490 | + configOptions: effectiveConfigOptions, | 473 | 491 | }; | | 492 | + const nextModels = | | 493 | + !useLiveCatalog && effectiveConfigOptions.length === 0 | | 494 | + ? withAcpRegistryDefaultModel(provider.models, selectedProbedModelId) | | 495 | + : modelsFromDiscovery( | | 496 | + discovery, | | 497 | + customModels, | | 498 | + previousModels.filter((model) => !model.isCustom), | | 499 | + ); | 474 | 500 | return { | 475 | 501 | ...snapshot, | 476 | 502 | status: provider.enabled ? "ready" : provider.status, | 477 | 503 | models: | 478 | | - !useLiveCatalog && configuration.configOptions.length === 0 | 479 | | - ? withAcpRegistryDefaultModel(provider.models, selectedProbedModelId) | 480 | | - : modelsFromDiscovery( | 481 | | - discovery, | 482 | | - customModels, | 483 | | - previousModels.filter((model) => !model.isCustom), | 484 | | - ), | | 504 | + dropUnmatchedModelOptions && effectiveConfigOptions.length > 0 | | 505 | + ? withAcpRegistryDefaultModel(nextModels, selectedProbedModelId) | | 506 | + : nextModels, | 485 | 507 | }; | 486 | 508 | } | 487 | 509 |
| |
|