In the registerTool() algorithm, the final insertion step writes the tool definition by indexing the internal context directly:
index.bs:453
Set this's internal context[|tool name|] to |tool definition|.
But a ModelContext's internal context is a model context struct, and a model context struct's only item is a tool map. Tools are meant to be keyed inside that tool map, not on the struct itself. Every other part of the spec reads/writes through the tool map:
The duplicate-name check earlier in the same algorithm: Let |tool map| be this's internal context's tool map … If |tool map|[|tool name|] exists (index.bs:354, :360)
unregister a tool: operates on internal context's tool map
perform an observation: reads internal context's tool map's values
Impact: A successfully registered tool is written to a location that unregister a tool and perform an observation never read, so per the literal spec text a registered tool would never be enumerated to agents and could never be unregistered. (Note the duplicate-name check at :360 reads the real tool map, so it also wouldn't observe tools inserted by this step — registering the same name twice would not be detected.)
Suggested fix: the |tool map| local is already in scope from :354; reuse it.
Set |tool map|[|tool name|] to |tool definition|.
Introduced in #179.
In the registerTool() algorithm, the final insertion step writes the tool definition by indexing the internal context directly:
index.bs:453
Set this's internal context[|tool name|] to |tool definition|.
But a ModelContext's internal context is a model context struct, and a model context struct's only item is a tool map. Tools are meant to be keyed inside that tool map, not on the struct itself. Every other part of the spec reads/writes through the tool map:
The duplicate-name check earlier in the same algorithm: Let |tool map| be this's internal context's tool map … If |tool map|[|tool name|] exists (index.bs:354, :360)
unregister a tool: operates on internal context's tool map
perform an observation: reads internal context's tool map's values
Impact: A successfully registered tool is written to a location that unregister a tool and perform an observation never read, so per the literal spec text a registered tool would never be enumerated to agents and could never be unregistered. (Note the duplicate-name check at :360 reads the real tool map, so it also wouldn't observe tools inserted by this step — registering the same name twice would not be detected.)
Suggested fix: the |tool map| local is already in scope from :354; reuse it.
Set |tool map|[|tool name|] to |tool definition|.
Introduced in #179.