Skip to content

Add agent skill guidance on avoiding deep attribute nesting across layers#1712

Merged
nathanjmcdougall merged 2 commits intomainfrom
copilot/improve-agent-config-layers
Apr 1, 2026
Merged

Add agent skill guidance on avoiding deep attribute nesting across layers#1712
nathanjmcdougall merged 2 commits intomainfrom
copilot/improve-agent-config-layers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

Code that accesses deeply nested attributes like result.solution.root and then operates on the internals (indexing, type assertions) is reaching through abstraction layers. This signals the logic belongs in the lower layer that owns those objects.

Adds a new section to the usethis-python-code skill (v1.3 → v1.4) covering:

  • Procedure for identifying and resolving deep nesting by moving logic down or adding interfaces
  • Concrete example contrasting the anti-pattern with the preferred approach
  • Common mistakes: extracting to local variables (hides but doesn't fix), adding type assertions at the wrong layer, adding thin wrappers instead of moving logic
# Bad: caller knows internal structure of result.solution
flat = result.solution.root
idx = flat.index(step_name)
predecessor = flat[idx - 1] if idx > 0 else None

# Good: lower layer encapsulates the logic
predecessor = result.get_predecessor(step_name)

…his-python-code skill

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/87dbd079-616c-4a9d-bd15-ead3babe8b5d

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor agent config to discourage mixed abstraction layers Add agent skill guidance on avoiding deep attribute nesting across layers Apr 1, 2026
Copilot AI requested a review from nathanjmcdougall April 1, 2026 10:44
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 1, 2026 10:47
@nathanjmcdougall nathanjmcdougall merged commit 3a22fca into main Apr 1, 2026
1 check passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/improve-agent-config-layers branch April 1, 2026 10:56
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.

Agent config to discourage code being placed in similar layers with mixed abstractions

2 participants